json class : Count getter

Description

Gets the number of direct child elements of the instance.

Syntax

jsonInstance.Count

Arguments

None

Return value

ClassDescription
intA number of direct child elements of the instance.

Sample code

1:

json jsonIns = new json("{@name@:@suzuki@,@age@:1}".Replace("@","".DQ)); // object

2:

int childCount = jsonIns.Count; // 2

3:

jsonIns = new json("[@name@,true,1000,null]".Replace("@","".DQ)); // array

4:

childCount = jsonIns.Count; // 4

Notes

If the instance is an array, it returns the number of values that are direct children. If the instance is an object, returns the number of members that are direct children.

Links for reference

None.

Copyright © Cooker All rights reserved.