Re: Euphoria JSON parser

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu