Jump to content

Write code questions using Json Class(USC).


photo

Recommended Posts

Posted

How do I get array elements using Json Class(USC)? I have an error trying to use the getChild(int num, variable var) function.

Posted

Hi,

our json parser currently support only vec2/vec3/vec4 as an array types.

Here an example how you can access this json file

{
  "array_test": [ 0, 0, 1 ]
}

via Unigine Script:

{
	Json j = new Json();
	if (j.load("test.json") == false)
		return;
	
	Json a = j.getChild(0); // Get "array_test" child
	vec3 v = a.getVec3(); // Get it's value

	log.message("%f %f %f\n", v.x, v.y, v.z);
}


Best regards.

  • Thanks 1
×
×
  • Create New...