How can I remove white space in the following code block and store in a javascript variable?
This is original format
JavaScript
x
10
10
1
{ "info":"First Json",
2
"description":"Official Website",
3
"timestamp":"1337936081",
4
"rates":{
5
"USD":"840",
6
"CHF":"1319",
7
"BDT":"298",
8
}
9
}
10
This is the format I want
JavaScript
1
2
1
{"info":"Central Bank of Myanmar","description":"Official Website of Central Bank of Myanmar","timestamp":"1337936081","rates":{"USD":"840","CHF":"1319","BDT":"298","SGD":"632","JPY":"1053","GBP":"887","AUD":"759"}}
2
Advertisement
Answer
JavaScript
1
2
1
var jsonWithWhitespaceRemoved = JSON.stringify(JSON.parse(variableWithJsonWhitespace))
2