top of page
  • Vishwas Gagrani

Parsing JSON in Haxe (OpenFL API)

To parse a Json string you need to use an Array of Object. And then the Object fields can be accessed using Reflection.

import openfl.utils.Object; 
import openfl.Assets;
import openfl.display.*;
import haxe.Json ;
  
class Main extends Sprite 
{
	public function new () 
	{

 		super ();
 		var myJson_arr:Array<Object>  =Json.parse('[
 {"a": "123","b":"456"},
 {"a": "233","b":"570"}');
  		 
 		trace(Reflect.field(myJson_arr[0],"a")); // 123
 		trace(Reflect.field(myJson_arr[1],"b")); //570 
 
 	}
}

0 views

Recent Posts

See All

You get the following error when trying to move the mouse cursor over any part of canvas. Access to XMLHttpRequest at ‘file:///……png’ from origin ‘null’ has been blocked by CORS policy: Cross origin r

bottom of page