Formats the given JSON Entity into a standardized JSON string.
Result = SRP_Json(Handle, "Stringify", Style, TabSize, Sorted, EscapeSolidus)
The JSON output.
|Handle||Handle to a JSON Entity. Required.|
|Style||The formatting style of the final output: Fast, DropNulls, or Styled. Optional.|
|TabSize||The size of tabs in characters. Optional.|
|Sorted||Determines if object members should be sorted in the output. Optional.|
|EscapeSolidus||Determines if '\/' represents the solidus character. Optional.|
If you are styling the output, you can optionally set the "TabSize" parameter to establish the size of tabs in characters. The default is 4.
Whether you style the output or not, you can opt to have object members sorted in the output. By definition, JSON object members are unordered, and you should never expect a particular member to be in a particular order. However, for large objects, sorting members could be a nice convenience for some users. Set "Sorted" to 1 to make it happen.
The "EscapeSolidus" parameter was added to give you a choice on how to handle the '\/' sequence. In the JSON spec, this is supposed to be translated into unicode character 0x002F, also known as the solidus character. The JSON community, however, treats this as optional. By default, the parameter is 0, but you can set it to 1 if you need the solidus character. The solidus character is very rarely needed, which is why the community just ignores it most of the time. Hence, the default is 0.
// Create a JSON array, add elements to it, and Stringify it fast If SRP_Json(ArrayHandle, "New", "Array") then SRP_Json(ArrayHandle, "AddValue", "12345") SRP_Json(ArrayHandle, "AddValue", 67890, "Number") SRP_Json(ArrayHandle, "AddValue", 1, "Boolean") JSON = SRP_Json(ArrayHandle, "Stringify", "Fast") SRP_Json(ArrayHandle, "Release") end // Create a JSON object, add members to it, and Stringify it pretty If SRP_Json(ObjectHandle, "New", "Object") then SRP_Json(ObjectHandle, "SetValue", "name", "John Doe") SRP_Json(ObjectHandle, "SetValue", "city", "Washington D.C.") JSON = SRP_Json(ObjectHandle, "Stringify", "Styled") SRP_Json(ObjectHandle, "Release") end