I am using Node.js (with Express.js) to pass a JSON data object from the server to the client view.
When I render the JSON object directly to the view I get the JSON object shown on the page as expected (this WORKS):
pageprovider.findAllTag( function(error, pages){
res.send(pages);
})
And my output looks like this (much bigger, many nested obj)
{"green":{"title":"green","pagesContaining": ""}}
When I try to pass it to my Jade View like this:
pageprovider.findAllTag( function(error, tagsJSONObj){
//res.send(pages);
pageprovider.findAll( function(error, pages){
res.render('search_tags.jade', { locals: {
title: 'Search by Tags',
'pages': pages,
tagsJSON: JSON.stringify(tagsJSONObj) //pass the tags data as a JSON obj
}
});
}) //pageprovider.findAll
}) //pageprovider.findAllTag
The problem
When I pass 'tagsJSON' to the view, the output includes the html entities:
var obj = jQuery.parseJSON( "{"name": 'value'}");
JQuery throws an error because it doesn't like '"'. How can I get Node to give me the proper quote, or get jQuery to accept this format?
Any thoughts?