jsonAddString

Adds a string with no key, as an element of an array. Takes json string and value string. Returns modified json via ReturnString.

JSON

Parameters & Returns

Parameters

json String
value String

Returns

String

Quick Summary

Adds a string with no key, as an element of an array. Takes json string and value string. Returns modified json via ReturnString.

Technical Exegesis...

Adds a string with no key, as an element of an array. Takes json string and value string. Adds a comma first if one is needed, then appends "value" (quotes and other special characters escaped, as jsonWriteString does). Returns the modified json.

Use between jsonBeginArrayField and jsonEndArrayField for an array of plain strings, such as "hobbies": ["Reading", "Cycling"]. jsonWriteString always writes a key, so it is for object fields, not array elements.

Example

Example.bam
Local json:String = jsonBegin()
json = jsonBeginArrayField(json, "hobbies")
json = jsonAddString(json, "Reading")
json = jsonAddString(json, "Cycling")
json = jsonEndArrayField(json)
json = jsonEnd(json)
Print json   ; {"hobbies":["Reading","Cycling"]}