JSON.Stringify: Difference between revisions
Jump to navigation
Jump to search
m Ghenne moved page Json.stringify to JSON.Stringify |
No edit summary |
||
Line 1: | Line 1: | ||
JSON.Stringify (''object''[, ''replacer'']) | |||
== Description == | == Description == | ||
JSON.Stringify converts an 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 == | == Example == | ||
<pre> | <pre> | ||
Rem | 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 30: | Line 30: | ||
== Related Items == | == Related Items == | ||
[[ | [[JSON.Parse|JSON.Parse]] | ||
[[Category:Language Reference]] | [[Category:Language Reference]] | ||
[[Category:Miscellaneous]] | [[Category:Miscellaneous]] |
Revision as of 11:49, 6 November 2012
JSON.Stringify (object[, replacer])
Description
JSON.Stringify converts an 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]}