jsonGetObjectKey

Gets the name of one field of an object that's the value of a field. Takes the JSON text, the field's name and the index of the field you want. Returns the field's name, or "" if there's no such field, its value isn't an object, or the index is out of range.

JSON

Parameters & Returns

Parameters

json String
key String
index Int

Returns

String

Quick Summary

Gets the name of one field of an object that's the value of a field. Takes the JSON text, the field's name and the index of the field you want. Returns the field's name, or "" if there's no such field, its value isn't an object, or the index is out of range.

Technical Exegesis...

Gets the name of one field of an object that's the value of a field. Takes the JSON text, the field's name and the index of the field you want, from 0 to jsonGetObjectCount - 1, in the order they're written. Returns the field's name, or "" if there's no such field, its value isn't an object, or the index is out of range.

Read the field's value with jsonReadString, jsonReadInt and so on, from the object jsonReadObject gives you.

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}}
Print jsonGetObjectKey(j, "address", 0)   ; city
Print jsonGetObjectKey(j, "address", 1)   ; zip
Print jsonGetObjectKey(j, "", 1)          ; address