You Are Here:

Community: Developer Discussion Boards

#1 Old Cool [announce] Simplejson 2.0.8 for S60 - 2009-02-16, 14:39

Join Date: Nov 2007
Posts: 494
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Offline
Forum Nokia Champion
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).


Marcelo Barros
Nokia E71, N800, N95, XM5800, N900
http://www.croozeus.com
http://blog.nokiabr.com.br
Reply With Quote

#2 Old Re: [announce] Simplejson 2.0.8 for S60 - 2009-02-16, 20:31

Join Date: Sep 2005
Posts: 320
Location: Finland, Helsinki
aaaaapo
Offline
Regular Contributor
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?
Reply With Quote

#3 Old Re: [announce] Simplejson 2.0.8 for S60 - 2009-02-16, 21:21

Join Date: Nov 2007
Posts: 494
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Offline
Forum Nokia Champion
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


Marcelo Barros
Nokia E71, N800, N95, XM5800, N900
http://www.croozeus.com
http://blog.nokiabr.com.br
Reply With Quote

#4 Old Re: [announce] Simplejson 2.0.8 for S60 - 2009-02-17, 08:47

Join Date: Sep 2005
Posts: 320
Location: Finland, Helsinki
aaaaapo
Offline
Regular Contributor
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)
Reply With Quote

#5 Old Re: [announce] Simplejson 2.0.8 for S60 - 2009-02-17, 17:21

Join Date: Nov 2007
Posts: 494
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Offline
Forum Nokia Champion
Quote:
Originally Posted by aaaaapo View Post
Here you are, in 2 files ...
Thanks aaaaapo, they will be useful.


Marcelo Barros
Nokia E71, N800, N95, XM5800, N900
http://www.croozeus.com
http://blog.nokiabr.com.br
Reply With Quote

#6 Old [announce] Simplejson 2.0.9 for S60 - 2009-03-10, 12:39

Join Date: Sep 2005
Posts: 320
Location: Finland, Helsinki
aaaaapo
Offline
Regular Contributor
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/
Reply With Quote

#7 Old Re: [announce] Simplejson 2.0.9 for S60 - 2009-03-10, 12:55

Join Date: Nov 2007
Posts: 494
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Offline
Forum Nokia Champion
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.


Marcelo Barros
Nokia E71, N800, N95, XM5800, N900
http://www.croozeus.com
http://blog.nokiabr.com.br
Reply With Quote

#8 Old Re: [announce] Simplejson 2.0.9 for S60 - 2009-03-10, 13:34

Join Date: Sep 2005
Posts: 320
Location: Finland, Helsinki
aaaaapo
Offline
Regular Contributor
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/
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
[announce] S60 simplejson cyke64 Python 0 2006-12-28 13:21

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2010 Nokia