JSON.Stringify: Difference between revisions
Jump to navigation
Jump to search
Created page with "JSON.STRINGIFY (''object''[, ''replacer'']) '''Description''' JSON.STRINGIFY converts an NS Basic object to a string. The data is saved in JSON format, which is a widely use..." |
No edit summary |
||
Line 1: | Line 1: | ||
Json.Stringify (''object''[, ''replacer'']) | |||
== Description == | |||
Json.Stringify converts an NS Basic object to a string. The data is saved in Json format, which is a widely used standard for exchanging data. Many platforms and programming languages provide Json unpacking routines. ''object'' is the object to be converted. ''replacer'' is an optional function to reformat the values. | |||
== Example == | |||
<pre> | <pre> | ||
Rem Json.Stringify Example | |||
myObject={a:"12355", b:2, c:[1,2,3,4]} | myObject={a:"12355", b:2, c:[1,2,3,4]} | ||
s= | s=Json.Stringify(myObject, replacer) | ||
Print "MyObject as a string: " & s | Print "MyObject as a string: " & s | ||
Line 22: | Line 22: | ||
</pre> | </pre> | ||
== Output == | |||
<pre> | <pre> | ||
Line 28: | Line 28: | ||
</pre> | </pre> | ||
== Related Items == | |||
[[json.parse|JSON.PARSE]] | [[json.parse|JSON.PARSE]] | ||
[[Category:Language Reference]] |
Revision as of 01:54, 17 August 2012
Json.Stringify (object[, replacer])
Description
Json.Stringify converts an NS Basic object to a string. The data is saved in Json format, which is a widely used standard for exchanging data. Many platforms and programming languages provide Json unpacking routines. object is the object to be converted. replacer is an optional function to reformat the values.
Example
Rem Json.Stringify Example myObject={a:"12355", b:2, c:[1,2,3,4]} s=Json.Stringify(myObject, replacer) Print "MyObject as a string: " & s Function replacer(key, value) If key="b" Then replacer=value*2 'Just for fun, we'll save double the value of b. Else replacer=value End If End Function
Output
MyObject as a string: {"a":"12355","b":4,"c":[1,2,3,4]}