I've a JSON object and I want to display it in Code Mirror. Code Mirror expects string only. When I do JSON.stringify it screws up the values where it is an array instead of just string.
eg. This is the output of JSON.stringify
{
"version": "1.1",
"sid": "ManagementService",
"svcVersion": "0.1",
"oid": "getCurrentStatsForServiceTypes",
"params": {
"serviceTypes": "[\"rest\", \"wsdl\", \"database\", \"rss\"]"
}
}
I want output as...
{
"version": "1.1",
"sid": "ManagementService",
"svcVersion": "0.1",
"oid": "getCurrentStatsForServiceTypes",
"params": {
"serviceTypes":["rest", "wsdl", "database","rss"]
}
}
In short I want to convert the Type from Object to String without affecting the value.
Update: JSON Object is
{
"version": "1.1",
"sid": "ManagementService",
"svcVersion": "0.1",
"oid": "getCurrentStatsForServiceTypes",
"params": {
"serviceTypes":["rest", "wsdl", "database","rss"]
}
}
I want the same as a string. Something like this should work.
'{
"version": "1.1",
"sid": "ManagementService",
"svcVersion": "0.1",
"oid": "getCurrentStatsForServiceTypes",
"params": {
"serviceTypes":["rest", "wsdl", "database","rss"]
}
}'
Blockquote