cancel
Showing results for 
Search instead for 
Did you mean: 

JSON parsing in Alfresco Javascript

alrice
Champ in-the-making
Champ in-the-making
Greetings I just read all the posts about JSON, but hope to clarify something. I need to parse JSON on the server side in my Web Client javascript. I was able to import this script http://www.json.org/json_parser.js and call the json_parse function like below. This is an implementation that does not eval() the json, which is better security -wise obviously. The appending of the empty string apparently converts the object type into a javascript string, which is then parse able by the function. Otherwise it fails.
var sJSON = oChild.content + "";
var oJSON = json_parse(sJSON);
My question is :doesn't Rhinoscript provide a built-in way to parse and stringify JSON ? I read in another post about Rhino's toSource() method, however didn't really understand the intended use. Thanks in advance .

(Alf 2.1.3E)
1 REPLY 1

alrice
Champ in-the-making
Champ in-the-making
Although since Rhinoscript has this automatic Java bridging, I can call a function to parse JSON in Java , and return a JSONObject. The syntax is different to access the data on the javascript  side , but the parsing is 50x to 100x faster in Java!!! I like the flexibility.  Smiley Very Happy