JSON: Difference between revisions
Content deleted Content added
added ocaml |
|||
Line 266: | Line 266: | ||
>>> sample |
>>> sample |
||
{'blue': [1, 2], 'ocean': 'water'} |
{'blue': [1, 2], 'ocean': 'water'} |
||
>>> data |
|||
{'foo': 1, 'bar': [10, 'apples']}</lang> |
|||
Because most of JSON is valid Python syntax (except "true", "false", and "null", and a few obscure escape sequences), it is also possible (but not recommended) to parse JSON using eval(): |
|||
<lang python> |
|||
>>> true = True; false = False; null = None |
|||
>>> data = eval('{ "foo": 1, "bar": [10, "apples"] }') |
|||
>>> data |
>>> data |
||
{'foo': 1, 'bar': [10, 'apples']}</lang> |
{'foo': 1, 'bar': [10, 'apples']}</lang> |