Re: Euphoria JSON parser

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

These JSON sequences

constant JSON_DATA = { 
  "{\"key1\" : {\"key1.1\" : 2}, \"key2\" : 2}", 
  "[120,183,\"alpha\",\"beta\",\"gamma\"]", 
  "{\"age\" : 51.5, \"details\" : [120,183], \"embedded\" : { \"three\" : 3.0, \"arr\" : [1,2,3,\"alpha\",\"beta\",\"gamma\"]} }", 
  "{\"him\" : true, \"her\" : false, \"nothing\" : null }", 
  "{\"dog\" : {\"name\" : \"Rover\", \"gender\" : \"male\"}}", 
  "{\"configure\":[{\"access-control\":[{\"access-list\":[]}]},{\"slot\":[]},{\"system\":[{\"date-and-time\":[{\"sntp\":[{\"server\":[]}]}]},{\"syslog\":[]}]},{\"management\":[{\"login-user\":[]},{\"snmp\":[{\"community\":[]}]},{\"access\":[]},{\"tacacsplus\":[{\"group\":[]}]}]},{\"qos\":[{\"policer-profile\":[]},{\"shaper-profile\":[]},{\"wred-profile\":[]},{\"queue-block-profile\":[{\"queue\":[]}]},{\"queue-group-profile\":[{\"queue-block\":[]}]}]},{\"port\":[{\"l2cp-profile\":[]},{\"ethernet\":[]},{\"svi\":[]}]},{\"bridge\":[{\"port\":[]},{\"vlan\":[]}]},{\"flows\":[{\"classifier-profile\":[]},{\"flow\":[]}]},{\"router\":[{\"interface\":[{\"dhcp-client\":[]}]}]},{\"oam\":[{\"cfm\":[{\"maintenance-domain\":[{\"maintenance-association\":[{\"mep\":[]}]}]}]}]},{\"test\":[{\"rfc2544\":[{\"profile-name\":[]}]}]}]}" 
} 
 

are converted to this

result =  
.  [1] 
.  .  [1] "key1" 
.  .  [2] 
.  .  .  [1] 
.  .  .  .  [1] "key1.1" 
.  .  .  .  [2] 2 
.  [2] 
.  .  [1] "key2" 
.  .  [2] 2 
result =  
.  [1] 120 
.  [2] 183 
.  [3] "alpha" 
.  [4] "beta" 
.  [5] "gamma" 
result =  
.  [1] 
.  .  [1] "age" 
.  .  [2] 51.500000 
.  [2] 
.  .  [1] "details" 
.  .  [2] "x" 
.  [3] 
.  .  [1] "embedded" 
.  .  [2] 
.  .  .  [1] 
.  .  .  .  [1] "three" 
.  .  .  .  [2] 3 
.  .  .  [2] 
.  .  .  .  [1] "arr" 
.  .  .  .  [2] 
.  .  .  .  .  [1] 1 
.  .  .  .  .  [2] 2 
.  .  .  .  .  [3] 3 
.  .  .  .  .  [4] "alpha" 
.  .  .  .  .  [5] "beta" 
.  .  .  .  .  [6] "gamma" 
result =  
.  [1] 
.  .  [1] "him" 
.  .  [2] "true" 
.  [2] 
.  .  [1] "her" 
.  .  [2] "false" 
.  [3] 
.  .  [1] "nothing" 
.  .  [2] "null" 
result =  
.  [1] 
.  .  [1] "dog" 
.  .  [2] 
.  .  .  [1] 
.  .  .  .  [1] "name" 
.  .  .  .  [2] "Rover" 
.  .  .  [2] 
.  .  .  .  [1] "gender" 
.  .  .  .  [2] "male" 
result =  
.  [1] 
.  .  [1] "configure" 
.  .  [2] 
.  .  .  [1] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "access-control" 
.  .  .  .  .  [2] 
.  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "access-list" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  [2] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "slot" 
.  .  .  .  .  [2] "" 
.  .  .  [3] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "system" 
.  .  .  .  .  [2] 
.  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "date-and-time" 
.  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  [1] "sntp" 
.  .  .  .  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  .  .  .  [1] "server" 
.  .  .  .  .  .  .  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "syslog" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  [4] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "management" 
.  .  .  .  .  [2] 
.  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "login-user" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "snmp" 
.  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  [1] "community" 
.  .  .  .  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [3] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "access" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [4] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "tacacsplus" 
.  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  [1] "group" 
.  .  .  .  .  .  .  .  .  .  .  [2] "" 
.  .  .  [5] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "qos" 
.  .  .  .  .  [2] 
.  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "policer-profile" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "shaper-profile" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [3] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "wred-profile" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [4] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "queue-block-profile" 
.  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  [1] "queue" 
.  .  .  .  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [5] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "queue-group-profile" 
.  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  [1] "queue-block" 
.  .  .  .  .  .  .  .  .  .  .  [2] "" 
.  .  .  [6] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "port" 
.  .  .  .  .  [2] 
.  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "l2cp-profile" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "ethernet" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [3] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "svi" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  [7] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "bridge" 
.  .  .  .  .  [2] 
.  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "port" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "vlan" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  [8] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "flows" 
.  .  .  .  .  [2] 
.  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "classifier-profile" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "flow" 
.  .  .  .  .  .  .  .  [2] "" 
.  .  .  [9] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "router" 
.  .  .  .  .  [2] 
.  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "interface" 
.  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  [1] "dhcp-client" 
.  .  .  .  .  .  .  .  .  .  .  [2] "" 
.  .  .  [10] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "oam" 
.  .  .  .  .  [2] 
.  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "cfm" 
.  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  [1] "maintenance-domain" 
.  .  .  .  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  .  .  .  [1] "maintenance-association" 
.  .  .  .  .  .  .  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  [1] "mep" 
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  [2] "" 
.  .  .  [11] 
.  .  .  .  [1] 
.  .  .  .  .  [1] "test" 
.  .  .  .  .  [2] 
.  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  [1] "rfc2544" 
.  .  .  .  .  .  .  .  [2] 
.  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  [1] 
.  .  .  .  .  .  .  .  .  .  .  [1] "profile-name" 
.  .  .  .  .  .  .  .  .  .  .  [2] "" 

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

Search



Quick Links

User menu

Not signed in.

Misc Menu