开发者

Java 6 ScriptEngine and JSON.parse problem

开发者 https://www.devze.com 2022-12-22 02:54 出处:网络
The Rhino release that is included in Java 6 ScriptEngine does not have a JSON parser.I\'ve tried including crockfords JSON2.js in my script on the scriptengine.eval().When I try to do the JSON.parse,

The Rhino release that is included in Java 6 ScriptEngine does not have a JSON parser. I've tried including crockfords JSON2.js in my script on the scriptengine.eval(). When I try to do the JSON.parse, it ends up giving me a script error that .replace is an unknown function. .replace is referenced several places in JSON2, and it works fine inside 开发者_如何学Goa browser (IE7, IE8, FF3). Anyone see this and have a suggestion?


Thanks for loooking at this. I solved it. Pilot Error. Simply put, the string I was passing to JSON.parse was not a correct JSON string. It was a java object toString(). So, the error message was unhelpful, but I was giving bad content.

0

精彩评论

暂无评论...
验证码 换一张
取 消