jsonBeginObjectField

Begins an object as the value of a named field. Takes json string and key string. Returns modified json via ReturnString.

JSON

Parameters & Returns

Parameters

json String
key String

Returns

String

Quick Summary

Begins an object as the value of a named field. Takes json string and key string. Returns modified json via ReturnString.

Technical Exegesis...

Begins an object as the value of a named field. Takes json string and key string. Adds a comma first if one is needed, then appends "key":{ . Returns the modified json.

This is how a field holds a whole object, such as "address": {"city": "New York", "country": "USA"}. Between this and jsonEndObject, add the object's fields with jsonWriteInt/Double/String; objects and arrays can be nested inside it the same way. Close it with jsonEndObject.

Example

Example.bam
Local city:String = "New York"
Local json:String = jsonBegin()
json = jsonWriteString(json, "name", "John")
json = jsonBeginObjectField(json, "address")
json = jsonWriteString(json, "city", city)
json = jsonWriteString(json, "country", "USA")
json = jsonEndObject(json)
json = jsonEnd(json)
Print json   ; {"name":"John","address":{"city":"New York","country":"USA"}}