Tuesday, 14 March 2017

Format the pretty JSON object

I'm using Node.js to pretty-print a JSON object. This line

obj = JSON.stringify(obj, null, 1); 

results in:

 {
  "name": "Member",
  "type": "object",
  "properties": {
   "Id": {
    "type": "GUID",
    "description": "Unique identifier"
    },
   "Name": {
    "type": "string",
    "description": "Members name"
    }
 }

But I want it to look this way:

 {
  "name": "Member",
  "type": "object",
  "properties": {
   "Id": {"type": "GUID", "description": "Unique identifier"},
   "Name": {"type": "string", "description": "Members name"}
 }

How can I do this?



via vaka

No comments:

Post a Comment