I convert a NSDictionary
to JSON NSData
with the following line:
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:answers
options:NSJSONWritingPrettyPrinted
error:&err];
And pass it to server side, which is a PHP script. The script reads the JSON string as:
{
"A" : "1941",
"D" : "1699",
"B" : "1949",
"E" : "1823",
"C" : "1999"
}
How can I format the JSON string as 1 line, just like below?
{"A" : "1941", "D" : "1699", "B" : "1949", "E" : "1823", "C" : "1999"}
Is there any option other than NSJSONWritingPrettyPrinted
?
Quoth the documentation for
NSJSONWritingPrettyPrinted
;If you don't want to set any bits in the writing options mask, just pass zero for that parameter. (Or in Swift, an empty option-set, which looks just like an empty array:
[]
.)