Reputation: 1227
I am getting json data from mongodb and display it using res.json(data). The result looks like following human readable format.
{
"glossary": {
"title": "example glossary"
}
}
Is there a way I can display this in raw Json without blank spaces and put them in one line? For example, {"glossary":{"title":"example".....
Upvotes: 0
Views: 101
Reputation: 1074809
I find that very surprising (that it's rendering it that way). You might try res.send(JSON.stringify(data))
. By default, JSON.stringify
doesn't do any formatting.
Gratuitous JSON.stringify
example:
var data = {
"glossary": {
"title": "example glossary"
}
};
snippet.log(JSON.stringify(data));
<!-- Script provides the `snippet` object, see http://meta.stackexchange.com/a/242144/134069 -->
<script src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"></script>
Upvotes: 1