Never mind.. I got solution.
var jsontext = '{"firstname":"Jesper","surname":"Aaberg","phone":["555-0100","555-0120"]}';
var jsonObject = eval('(' + jsontext + ')');
var contact = jsonObject.firstname;
On Thursday, May 23, 2013 4:34:44 PM UTC-7, Jitendra Chopra wrote:
Hi
I wrote a function in Mongo DB which will parse a give JSON/XML document and give me object.
I will use that function for further processing.
When i have JSON parse it thrown below error. Can you please suggest is there any way we can parse JSON/XML Document?
"invoke failed: JS Error: ReferenceError: JSON is not defined nofile_b:11"
function (payload) {
var jsontext = '{"firstname":"Jesper","surname":"Aaberg","phone":["555-0100","555-0120"]}';
var contact = JSON.parse(jsontext);
return contact.firstname;
}
In Spring Java, i am using below code to invoke function
Object a = mongoTemplate.getDb().eval(function);