jsonAddInt

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

JSON

Parameters & Returns

Parameters

json String
value Int

Returns

String

Quick Summary

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

Technical Exegesis...

Adds a whole number with no key, as an element of an array. Takes json string and value integer. Adds a comma first if one is needed, then appends the number. Returns the modified json.

Use between jsonBeginArrayField and jsonEndArrayField for an array of numbers, such as "scores": [7, 12, -3]. jsonWriteInt always writes a key, so it is for object fields, not array elements. Read the elements back with jsonGetArrayCount and jsonGetArrayElement (ToInt turns an element into a number).

Example

Example.bam
Local json:String = jsonBegin()
json = jsonBeginArrayField(json, "scores")
json = jsonAddInt(json, 7)
json = jsonAddInt(json, 12)
json = jsonEndArrayField(json)
json = jsonEnd(json)
Print json   ; {"scores":[7,12]}