I have
public JSONObject parseXML(String xml) {
JSONObject jsonObject = XML.toJSONObject(xml);
return jsonObject;
}
from the org.json library.
In Nashorn I want to be able to do
let foo = parseXML(someXMLString);
console.log(foo.someProperty);
What I end up getting is a NPE. But if I do
let foo = parseXML(someXMLString);
console.log(JSON.parse(foo.someProperty));
it works. is there an equivalent function to JSON.parse I can do in Java land and return without needing that JSON.parse in JavaScript?
edit: Please note it is NOT a duplicate. I am not asking how to parse for certain values in the JSON, I am asking how to return the entire object, so that it is parseable by Nashorn without the extra JSON.parse