Suppose i have an array like:
var defaultSettings = [{
"calibrationHiFreq": 22000,
"high-pass-enable": true
}];
Then i serialize and deserialize it to JSON:
var json = JSON.stringify(defaultSettings);
var parsed = JSON.parse(json);
However the parsed variable is an object that does not contain the original quotes. Logging the object in Node.js shows the issue:
[ { calibrationHiFreq: 22000,
'high-pass-enable': true } ]
I know it works like this and unquoted and quoted names are interchangeable, but I am wondering if there is a way to force the serializer 'parsing' to be more consistent with the original object and keep the quotes as they were? It would certainly make the resulting object less ugly.
So my goal is that after deserialization the quoting in the resulting object is exactly the same as defined initially before serialization.
Aucun commentaire:
Enregistrer un commentaire