×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Cool [announce] Simplejson 2.0.8 for S60

    Hi People !

    Just an announce regarding simplejson.

    • I tried to use Aaron port of simplejson but I couldn´t find the encoder class.
    • No donuts for me when trying to use mobilepythonbook's json.py. Errors when using it in my application.


    So, I ported original simplejson 2.0.8 to S60, with few changes, fortunately.

    Source code here.
    Zip package here.
    Original simplejson ocumentation here.

    Have fun and give feedback ! I tested just a little, since my changes were really few. I saw that when using float numbers, numbers above 10^308 will return Inf (expected for C floats, at least).

  2. #2
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: [announce] Simplejson 2.0.8 for S60

    Quote Originally Posted by marcelobarrosalmeida View Post
    Just an announce regarding simplejson.

    • I tried to use Aaron port of simplejson but I couldn´t find the encoder class.
    • No donuts for me when trying to use mobilepythonbook's json.py. Errors when using it in my application.


    So, I ported original simplejson 2.0.8 to S60, with few changes, fortunately.

    Have fun and give feedback ! I tested just a little, since my changes were really few. I saw that when using float numbers, numbers above 10^308 will return Inf (expected for C floats, at least).
    I noticed too that encoder class was missing from Aaron's port. After adding encoder, simplejson has worked pretty well, although it is a bit bloat (importing it takes a few seconds). Anyway, it is the best json library I've tested yet in S60.

    I also noticed your port of simplejson contains four files. Wouldn't it make easier to use simplejson, if you combined all code into one file?

  3. #3
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: [announce] Simplejson 2.0.8 for S60

    Hi aaaaapo !

    Quote Originally Posted by aaaaapo View Post
    I noticed too that encoder class was missing from Aaron's port. After adding encoder, simplejson has worked pretty well, although it is a bit bloat (importing it takes a few seconds). Anyway, it is the best json library I've tested yet in S60.
    Could you publish your release anywhere ? One more good option for us, certainly.

    Quote Originally Posted by aaaaapo View Post
    I also noticed your port of simplejson contains four files. Wouldn't it make easier to use simplejson, if you combined all code into one file?
    I decided to keep classes/files as near as possible from original implementation, making easier any new merge. But this can be done, of course.

    Thanks for your comments.

    Marcelo Barros

  4. #4
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: [announce] Simplejson 2.0.8 for S60

    Quote Originally Posted by marcelobarrosalmeida View Post
    Could you publish your release anywhere?
    Here you are, in 2 files (place them in E:\Python\lib if you want to use them in scripts):

    http://code.google.com/p/pys60gps/so..._simplejson.py
    http://code.google.com/p/pys60gps/so...lib/encoder.py

    This bases on Aaron's port. I think encoder class could be included in pys60_simplejson.py.

    Usage:

    Code:
    import pys60_simplejson
    simplejson = pys60_simplejson.simplejson()
    data = {"foo":42, "bar":"baz"}
    simplejson.dumps(data)

  5. #5
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: [announce] Simplejson 2.0.8 for S60

    Quote Originally Posted by aaaaapo View Post
    Here you are, in 2 files ...
    Thanks aaaaapo, they will be useful.

  6. #6
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    [announce] Simplejson 2.0.9 for S60

    Quote Originally Posted by marcelobarrosalmeida View Post
    I decided to keep classes/files as near as possible from original implementation, making easier any new merge. But this can be done, of course.
    Inspired by Marcelo I created simple shell script which merges all necessary simplejson (at least version 2.0.9 works fine) files to a single simplejson.py. It seems to work at least as well as my previous try (which bases on Aaron's port).

    You can download it from PyS60GPS codebase:
    http://code.google.com/p/pys60gps/so.../simplejson.py

    I probably can and will maintain this at least as long as I use PyS60 1.4-series.

    It would be nice if somebody has time to test this.
    Code:
    #!/bin/bash
    # http://code.google.com/p/pys60gps/source/browse/trunk/bin/do_pys60_simplejson.sh
    # Aapo Rista 2009
    # Usage: download and extract simplejson 2.0.9 and execute this file in 
    # the directory which contains FILES listed below:
    
    FILES="decoder.py encoder.py scanner.py __init__.py"
    TARGET=simplejson.py
    TEST_SCRIPT=test_simplejson.py
    
    # File header
    echo "'''
    PyS60 1.4.x compatible simplejson
    
    2009 Created by Aapo Rista (ispired by Marcelo Barros) from 
    simplejson 2.0.x with an ugly shell script. (But hey, it works!)
    '''
    
    from __future__ import generators
    basestring = (unicode, str)
    
    " > ${TARGET}
    
    grep -h -e ^__author__ ${FILES} | sort -u >> ${TARGET}
    # Unify imports
    grep -h -e ^import ${FILES} | sort -u >> ${TARGET}
    
    # Remove docstrings and imports
    perl -ne 'push(@l, $_);END{$a=join("", @l); $a=~s/r?""".*?"""//msg;print $a}' \
       decoder.py encoder.py scanner.py __init__.py | \
       grep -v \
            -e ^from \
            -e ^import \
            -e ^__author__ \
            >> ${TARGET}
    
    # Python 2.2 does not support ::-notation (every other item of a list)
    perl -i -pe 's/_BYTES = .*\]$/_BYTES = "00008FF70000000000000FF700000000".decode("hex")/' ${TARGET}
    # Delele all single line __all__ definitions
    perl -i -pe 's/^__all__ = .*\]$//' ${TARGET}
    
    # Thats it!
    
    # Very simple test case:
    echo '
    import simplejson
    data = { 
    "foo" : u"\xe4", 
    "bar" : 3.14159,
    "baz" : "hello!",
    }   
        
    json = simplejson.dumps(data)
    print json, data["foo"]
    data = simplejson.loads(json)
    print data, data["foo"]
    ' > ${TEST_SCRIPT}
    --
    Aapo Rista
    http://code.google.com/p/pys60gps/
    http://opennetmap.org/

  7. #7
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: [announce] Simplejson 2.0.9 for S60

    Hi Aapo ! Great job ! I will test it in next days and give you some feedback. How about open a google code project ? I think it is better to keep this port in a specific place and not only in ours projects. If you agree, I will create it.

  8. #8
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: [announce] Simplejson 2.0.9 for S60

    Quote Originally Posted by marcelobarrosalmeida View Post
    Hi Aapo ! Great job ! I will test it in next days and give you some feedback. How about open a google code project ? I think it is better to keep this port in a specific place and not only in ours projects.
    I think it is a bit overkill to create a google code project for single file (which may be obsolete when Pys60 2.0 arrives). But I agree it is better to keep it some general place. Perhaps someone could contact the author of simplejson (Bob Ippolito) and tell him we have this kind of port?

    Actually simplejson seems to be in google code already:
    http://simplejson.googlecode.com/svn...ocs/index.html
    --
    Aapo Rista
    http://code.google.com/p/pys60gps/
    http://opennetmap.org/

Similar Threads

  1. [announce] S60 simplejson
    By cyke64 in forum Symbian
    Replies: 0
    Last Post: 2006-12-28, 12:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •