jsonGetObjectCount

Category: JSON

Syntax:

jsonGetObjectCount:Int(json:String, key:String)


Parameters

Returns

Int



Summary

Counts the fields of an object that's the value of a field.

Takes the JSON text and the field's name.

Returns how many fields the object has, or 0 if there's no such field or its value isn't an object.

View detailed documentation online



Example
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}}
For i:Int = 0 To jsonGetObjectCount(j, "address") - 1
	Print jsonGetObjectKey(j, "address", i)   ; city, then zip
Next
Print jsonGetObjectCount(j, "")   ; 2 (name and address)

BambooBasic © 2026 Michael Denathorn