Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8149427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:50:57+00:00 2026-06-06T14:50:57+00:00

I am using Node.js (with Express.js) to pass a JSON data object from the

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:50:58+00:00Added an answer on June 6, 2026 at 2:50 pm

    It’s because when you call

        res.render('search_tags.jade', { locals: {
            title: 'Search by Tags',
            'pages': pages,
            tagsJSON: JSON.stringify(tagsJSONObj) //pass the tags data as a JSON obj
            }
        });
    

    search_tags.jade is meant to output HTML, so it encodes your quotes. You should use a renderer that doesn’t HTML escape, or at least change your view so that your params aren’t HTML encoded

    If you don’t want something in the output escaped, use !{tagsJSON} within the view. However, when outputting JSON, there’s no need for a view. you can just take your object, call JSON.stringify. I don’t use JADE so I’m not sure if there is a way to create view that can just call JSON.stringify(), but that’s what I’ve done in JSP, velocity, ASP, PHP and Code Igniter (not using JSON.stringify, instead it uses a JSON tool for the given language)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using node.js with express. I read out data from MongoDB with Mongoose
I'm trying to send the node instance JSON data using an ajax get request
I have the following express node.js app. It's using the 'redis' npm package. app.get(/test,function(req,res){
I'm using Node.js and Express, and I want to pass a local variable in
I am using node and express. To register a controller I call: app.get('/user/:id', function
I'm using Node.JS and Express web framework, I have a problem with the res.render()
I would like to pass the JSON object along with the view when I
I am using node.js and express, and I am calling server-side functions and syncing
I'm (almost) successfully using Node.js with Express and Redis to handle sessions. The problem
I'm successfully using Node.js + Express + Everyauth ( https://github.com/abelmartin/Express-And-Everyauth/blob/master/app.js ) to login to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.