Re: Euphoria JSON parser
- Posted by petelomax Mar 27, 2017
- 2035 views
For anyone interested, I have just pushed a new builtins/json.e module to the Phix repository (see https://bitbucket.org/petelomax/phix/src ), which should be compatible with OpenEuphoria.
Example use:
include builtins/json.e puts(1,"roundtrip (10 examples):\n") sequence json_strings = {"{\"this\":\"that\",\"age\":{\"this\":\"that\",\"age\":29}}", "1", "\"hello\"", "null", "[12]", "[null,12]", "[]", "{\"this\":\"that\",\"age\":29}", "{}", "[null,[null,12]]"} for i=1 to length(json_strings) do string s = json_strings[i] puts(1,s&"\n") object json_object = parse_json(s) puts(1,print_json("",json_object,true)&"\n") if not equal(print_json("",json_object,true),s) then ?9/0 end if end for
I would be interested to hear any tales of success or failure with it.
Pete