tags:

views:

39

answers:

2

The JSON syntax is very simple but also very strict with names and strings. So i am looking for a JSON library that allows some relaxed syntax for strings.

Any token not startng with [0-9],:[]{}" and not is true, false or null is a valid name/string.

So that this 2 JSON are equivalent

{
  "name":"Eric",
  "addr":"461, Ocean Boulevard"
}

{
  name:Eric,
  addr:"461, Ocean Boulevard"
}

Update I googled again and found RSON for Python, something similar for Java ?

+1  A: 

At least Google Gson allows it for keys. No one comes to mind which does the same for values, but it's invalid in real JavaScript anyway.

BalusC
+1  A: 

Your best bet is likely to write a small converter class, which can translate to and from your "quasi-JSON". Should take less than an hour, and then you're free to use whatever standard library you please.

Update: Since you've found a Python script that does what you want, and since that "RSON" code is pretty straightforward and self-contained in a single file... why not simply embed it your Java app using the http://www.jython.org/ library?

Steve Perkins
Less than 1 hour, i doubt. To do it well, i have to write a JSON parser anyway ...
PeterMmm
It doesn't have to understand full-blown "JSON"... it only has to understand "strings that are missing their double-quotes". Perhaps more than an hour to thoroughly test and make it bullet-proof, but it's still far less ambitious that a complete JSON parser.
Steve Perkins
Never mind... updated the answer.
Steve Perkins