JSON: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: use backtick strings rather than escaped \") |
No edit summary |
||
Line 1,525: | Line 1,525: | ||
"ocean":{"water":["cold","blue"]}} |
"ocean":{"water":["cold","blue"]}} |
||
</pre> |
</pre> |
||
=={{header|Forth}}== |
|||
Forth has no built-in higher level data structures such as arrays, |
|||
dynamically resizeable arrays, strings, dynamically resizeable |
|||
strings, and objects. There is no standardized Forth library to build |
|||
and use such structures. But there are many different Forth libraries, |
|||
written by individuals, available. Though finding them is not always easy. |
|||
The syntax and behavior is different for each. |
|||
The library code used below can be found here: |
|||
https://github.com/DouglasBHoffman/FMS2 |
|||
Load a JSON string into a data structure. |
|||
<pre> |
|||
s\" {\"value\":10,\"flag\":false,\"array\":[1,2,3]}" $>json value j |
|||
j :. |
|||
</pre> |
|||
Prints a JSON as follows: |
|||
{ |
|||
"value": 10, |
|||
"flag": false, |
|||
"array": [ 1, 2, 3] |
|||
} |
|||
Create a new data structure and serialize it into JSON. |
|||
<pre> |
|||
j{ "another":"esc\"aped" }j 1 j :insert |
|||
j :. |
|||
</pre> |
|||
Prints the modified JSON: |
|||
{ |
|||
"value": 10, |
|||
"another": "esc"aped", |
|||
"flag": false, |
|||
"array": [ 1, 2, 3] |
|||
} |
|||
Convert the JSON object into a string. Print the string. |
|||
<pre> |
|||
j json>$ :. |
|||
</pre> |
|||
{\"value\":10,\"another\":\"esc\"aped\",\"flag\":false,\"array\":[1,2,3]} |
|||
=={{header|Fortran}}== |
=={{header|Fortran}}== |