My web service responses has mimetype: "application/json" and my JSON outputs without spacing, like this
1
{"Data":{"Item":"123","Timestamp":"2011-11-24T17:50:43"}}
When the JSON should output like this
2
{
"Data":{
"Item":"123",
"Timestamp":"2011-11-24T17:50:43"
}
}
Is there any way I can fix the JSON format, so it appears like #2?
I wouldn’t change the format written out by the web service, but if you want to format it for diagnostic purposes you can use Json.NET to do this very simply:
The result is automatically formatted. You could put this into a small tool – either a desktop tool or a web page somewhere. (I wouldn’t be surprised if there were already online JSON formatters, although obviously you’d want to be careful about formatting sensitive data.)