Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Convert JS array of objects into Perl array of Hashes

by afoken (Chancellor)
on Dec 09, 2009 at 01:25 UTC ( [id://811846]=note: print w/replies, xml ) Need Help??


in reply to Re: Convert JS array of objects into Perl array of Hashes
in thread Convert JS array of objects into Perl array of Hashes

Anyone know how to make JSON::XS more tolerant?

JSON::XS has a "relaxed" mode (F_RELAXED in the XS code). Currently, it allows:

  • lists with a final comma (as in Perl)
  • Shell-style comments (from # to end of line) where JSON allowes white space

This looks like a proper way to allow unquoted keys and the like, you "just" have to modify the XS code.

The one thing that really drives me mad is the shell-style comment. Why on earth would someone want shell comments in JSON? JSON is derived from Javascript, and it is designed to be evaluateable by current browsers. Javascript has inherited its comment syntax from C and C++, i.e. // for single line comments and /* */ for comment blocks. I would like to see those comments supported by JSON::XS. No browser understands shell comments, so they should be removed.

A different approach could be a subclass that uses the incremental parsing feature.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://811846]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-25 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found