<%= json %> just calls json.toString() that by default just calls the Object#toString with prints the class-string of the object.
what exactly do you do with your object? to clarify names first:
1. there is a JSON object, that can parse json strings and create json strings
2. JSON is a serialization format: javascript object notation
3. There are object literals in java script. JSON is inspired by them, but they are not json
If you want to present your javascript object in some kind of HTML structure, then do html and access the properties if your object.
Am Freitag, 17. Mai 2013 02:52:07 UTC+2 schrieb Jake Isaac:
Hi
I have a question about retrieving a JSON object back from ejs. I think I understand the problem but I don't know how to solve it. I am passing JSON to the client, on the server it is in literal form but on the JSON side it displays as [object:object] when I do <%= json %>, I have tried using <%- json %> but I don't think it works I don't see any difference. Here is the code snippet if it helps:
index.js:
res.render('maps', {
title: "Title ",
json: json
});
maps.html:
<%- json %>
If I do json.forEach.... I can iterate over the values, so I know data is there.
thanks in advance
Jake