Java 6 ScriptEngine and JSON.parse problem

隐身守侯 提交于 2019-12-12 19:12:27

问题


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 a browser (IE7, IE8, FF3). Anyone see this and have a suggestion?


回答1:


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.



来源:https://stackoverflow.com/questions/2405410/java-6-scriptengine-and-json-parse-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!