How can I pass JSON to client using Node.js + HBS + Express?

Consider, I am sending JSON to client as follows in render page of Express (using hbs as a view engine):

res.render('MyPage.html', { layout: false, PageTitle: 'Project Name', JSON_Data: {field1:'value',field2:'value2'}});

I am able to access and set title of html page by using {{PageTitle}}, following is the code.

  <title>{{PageTitle}}</title>

Now I want to show JSON_data into alert popup.

I've tried following way, but getting Uncaught SyntaxError: Unexpected token {, while debugging in chrome is shows var jsonobj = [object Object]

    function fbOnBodyLoad() {
        var jsonobj = {{JSON_data}};
        alert(jsonobj);
    }

Could any body give some idea on How to access JSON_data and show in alert

Advance Thanks

to access the inner elements of the json object, try like this

var jsonobj = "{{JSON_data.field1}}";

may be this might solve the issue.

refer

Handlebars.js parse object instead of [Object object]

You could always register a Handlebars helper to format the object into a string format (such as by using JSON.stringify), and then use that helper in your view. http://handlebarsjs.com/block_helpers.html