JSON.stringify() differences between Android and iPhone
The following:
var data = {
'user' : {
'email' : emailField.value,
'password' : passwordField.value
}
};
parsed = JSON2.stringify(data);
Yields different results between Android(1.6 and 2.1) and iPhone(3.1) simulators (Titanium mobile 1.0). On the Android, all of the quotes around the keys and values are escaped with a backslash, whereas on the iPhone there are not.
I found that if I included the json2.js reference code from json.org, the results are inline with the iPhone results.
Anyone have any idea why the two platforms would be so different?
2 Answers
-
When the stringify'd content is sent to our server, it rejects it from the Android as malformed JSON because the keys are not encapsulated in quotes.
-
Is it causing problems with parsing or just looks different? We're using code in the Android SDK to convert to JSON. It's from json.org.