Well, all that JSONParser() does is to call eval() on the string. Try
wrapping the object in parenthesis:
$! Notice that the string is now quoted.
$! This simulates what that client receives.
$ head /tmp/foo.js
x ='{"projects":[{"id":"1","title":"Project Number
1","priority":"High","openDate":"2009-06-05","closeDate":"2009-06-07","owner
<snip>
Well I'm a Rhino man
Well, don't you know I am?
(apologies to F. Zappa)
$ rhino
js> load("/tmp/foo.js")
js> print(x.toSource())
(new String("{\"projects\":[{\"id\":\"1\",\"title\":\"Project Number
1\",\"priority\":\"High\",\"openDate\":\"2009-06-05\",\"closeDate\":\"2009-06-07\",\"owner\":
{\"firstName\":\"John\",\"lastName\":\"Doe\
<snip>
js> print (eval(x))
js: "<stdin>#4(eval)", line 1: uncaught JavaScript runtime exception:
SyntaxError: missing ; before statement
at <stdin>:4
<snip>
js> print(eval('('+x+')'))
[object Object]
Are they added in the parent?
Checking the trunk source, I don't see that concatenation:
public static JSONValue parse(String jsonString) {
if (jsonString == null) {
throw new NullPointerException();
}
if (jsonString.length() == 0) {
throw new IllegalArgumentException("empty argument");
}
try {
return evaluate(jsonString);
} catch (JavaScriptException ex) {
throw new JSONException(ex);
}
}
Well, yes. But the OP said he's using JSONParser.parse() How does
JSONValue.evaluate() get called in that scenario?
Oh, never mind. I figured it out.