JSON: Difference between revisions
Content added Content deleted
(Redirect to category) |
No edit summary |
||
Line 1: | Line 1: | ||
{{task}} |
|||
#REDIRECT [[:Category:JSON]] |
|||
Load a [[wp:JSON|JSON]] string into a data structure. Also create a new data structure and serialize it into JSON. |
|||
Use objects and arrays, and make sure your JSON is valid (http://www.jsonlint.com/). |
|||
=={{header|Python}}== |
|||
<lang Python>import json |
|||
data = json.loads('{ "foo": 1, "bar": [10, "apples"] }') |
|||
sample = { "blue": [1,2], "ocean": "water" } |
|||
json_string = json.dumps(sample) |
|||
</lang> |
|||
[[Category:Data Structures]] |
Revision as of 02:33, 25 August 2010
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
Load a JSON string into a data structure. Also create a new data structure and serialize it into JSON. Use objects and arrays, and make sure your JSON is valid (http://www.jsonlint.com/).
Python
<lang Python>import json data = json.loads('{ "foo": 1, "bar": [10, "apples"] }')
sample = { "blue": [1,2], "ocean": "water" } json_string = json.dumps(sample) </lang>