JysonEncodeMappings » History » Version 1
Alan Kennedy, 2009-03-17 08:38 PM
1 | 1 | Alan Kennedy | h1. How jyson maps jython objects to JSON objects. |
---|---|---|---|
2 | |||
3 | Jyson maps jython objects to JSON objects according to the following table. |
||
4 | |||
5 | |Jython object|Implementation type|JSON type|Example|Notes| |
||
6 | |None|org.python.core.Py.None|null|None=>null|| |
||
7 | |True, False|org.python.core.Py.True, org.python.core.Py.False|true,false|True=>true|| |
||
8 | |int|org.python.core.PyInteger|number|42=>42|| |
||
9 | |long|org.python.core.PyLong|number|42L=>42|| |
||
10 | |float|org.python.core.PyFloat|number|42.0=>42.0|| |
||
11 | |str|org.python.core.PyString|string|'Hello World!'=>"Hello World!"|| |
||
12 | |dict|org.python.core.PyDictionary, org.python.core.PyStringMap|object|{'hello': 1, 'world': 2}=>{"hello": 1, "world": 2}|Only dictionaries with string keys can be encoded, as according to the JSON spec. Any attempt to encode a dictionary with a non-string key will cause a JysonEncodeException. The values in a dictionary can be any JSON encodable type, including tuples, lists and dictionaries.| |
||
13 | |list|org.python.core.PyList|array|[1, 42, 'Hello world!']=>[1, 42, "Hello world!"]|List elements may be of any JSON encodable type, including tuples, lists and dictionaries| |
||
14 | |tuple|org.python.core.PyTuple|array|(1, 42, 'Hello world!')=>[1, 42, "Hello world!"]|Tuple elements may be of any JSON encodable type, including tuples, lists and dictionaries| |