-
Notifications
You must be signed in to change notification settings - Fork 2
JysonEncodeMappings
amak edited this page Aug 19, 2024
·
1 revision
Jyson maps jython objects to JSON objects according to the following table.
Jython object | Implementation type | JSON type | Example | Notes |
None | org.python.core.Py.None | null | None=>null | |
True, False | org.python.core.Py.True, org.python.core.Py.False | true,false | True=>true | |
int | org.python.core.PyInteger | number | 42=>42 | |
long | org.python.core.PyLong | number | 42L=>42 | |
float | org.python.core.PyFloat | number | 42.0=>42.0 | |
str | org.python.core.PyString | string | ‘Hello World!’=>"Hello World!" | |
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. |
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 |
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 |