JSON serializer/deserializer. Support identifiers without quotes, comments, single quotes and typed parsing (like `Newtonsoft.Json` library in C#). Based on `tjson` library.
Repository Haxelib Haxe Download
haxelib install jsonmod 1.0.0
JSON parser and encoder for Haxe. Based on TJSON library (by Jordan CM Wambaugh).
JSON format extended features:
/*comment*/
.//comment
.Features:
RTTI
(restore classes).@jsonIgnore
field meta to skip fields on serialization.Date
serialized as Float (used Date.getTime()
).Date
deserialized from Float (used Date.fromTime()
).import jsonmod.Json;
...
// parse string to object
var data = "{ key:'value' }";
var object = Json.parse(data);
// encode object to string
var json = Json.encode(object);
@:rtti // need for Json.parseTyped() to detect field types
class MyClass
{
@jsonIgnore // ignore `a` on serialization
var a = 1;
public var b = 2;
public function new() {}
}
var str = Json.encode(new MyClass()); // "{b:2}"
// parse with classes support
var parsedObject = Json.parseTyped("{ a:20, b:10 }", MyClass); // MyClass { a:20, b:10 }