| Reply | « Previous Thread | Next Thread » |
|
Join Date: Nov 2007
Posts: 310
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Offline
Forum Nokia Champion
|
|
Hi People !
Just an announce regarding simplejson.
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 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
|
Quote:
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? |
|
Join Date: Nov 2007
Posts: 310
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Offline
Forum Nokia Champion
|
||
|
Hi aaaaapo !
Quote:
Quote:
Thanks for your comments. Marcelo Barros Marcelo Barros Nokia E71, N800, N95 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
|
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) |
|
Join Date: Nov 2007
Posts: 310
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Offline
Forum Nokia Champion
|
|
Thanks aaaaapo, they will be useful.
Marcelo Barros Nokia E71, N800, N95 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
|
Quote:
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/ |
|
Join Date: Nov 2007
Posts: 310
Location: Sertaozinho/Brazil
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 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
|
Quote:
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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| [announce] S60 simplejson | cyke64 | Python | 0 | 2006-12-28 13:21 |