JSON.Stringify

From NSB App Studio
Revision as of 22:48, 8 July 2012 by Brendon (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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]}

Related Items

JSON.PARSE