jsonReadObject

Gets an object that's the value of a field, such as one written with jsonBeginObjectField. Takes the JSON text and the field's name. Returns the object as JSON text ("{...}"), or "" if there's no such field or its value isn't an object.

JSON

Parameters & Returns

Parameters

json String
key String

Returns

String

Quick Summary

Gets an object that's the value of a field, such as one written with jsonBeginObjectField. Takes the JSON text and the field's name. Returns the object as JSON text ("{...}"), or "" if there's no such field or its value isn't an object.

Technical Exegesis...

Gets an object that's the value of a field, such as one written with jsonBeginObjectField. Takes the JSON text and the field's name. Returns the object as JSON text ("{...}"), ready for jsonReadString, jsonReadInt and the other readers, or "" if there's no such field or its value isn't an object.

Use it when two objects have fields with the same name: the readers on their own take the first one they find.

Example

Example.bam
Local j:String = jsonBegin()
j = jsonWriteString(j, "name", "Mike")
j = jsonBeginObjectField(j, "address")
j = jsonWriteString(j, "city", "Berlin")
j = jsonWriteInt(j, "zip", 10115)
j = jsonEndObject(j)
j = jsonEnd(j)
; {"name":"Mike","address":{"city":"Berlin","zip":10115}}
Local addr:String = jsonReadObject(j, "address")
Print jsonReadString(addr, "city")   ; Berlin
Print jsonReadInt(addr, "zip")       ; 10115