How to get jsondecode to preserve map keys (numerical keys are prefixed with 'x')
Afficher commentaires plus anciens
Hi,
Could someone explain why this happens:
jsonencode(jsondecode('{"a":"b"}'))
% '{"a":"b"}' (works as one would assume)
jsonencode(jsondecode('{"1":"b"}'))
% '{"x1":"b"}' (numeric value is previxed with 'x')
jsonencode(jsondecode('{"a.b":"b"}'))
% '{"a_b":"b"}' ('.' is converted to '_')
And how to work around it?
Some context:
I'm utilising a web api endpoint to post data, and it requires the data in similar format that in the second case above. But I'm not able to produce reliably the json payload (the example is a simplification of the actual problem)
Thanks
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur JSON Format dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!