jsondecode: preserve original string

14 Ansichten (letzte 30 Tage)
Elena Barbieri
Elena Barbieri am 5 Jul. 2022
Kommentiert: Rik am 6 Jul. 2022
I would like to preserve the original string (that contains unicode characters??) when I use the function jsondecode.
Example:
jsontext='{"IDs":"\u00b0C"}'
Data=jsondecode(jsontext)
Result obtained:
Data =
struct with fields:
IDs: '°C'
Desired result:
Data =
struct with fields:
IDs: '\u00b0C'
Thanks for the help!

Akzeptierte Antwort

Rik
Rik am 6 Jul. 2022
If the jsondecode function does not mention this as an option, it is not possible without modifying the code, which you should not do for an internal function.
I have written a JSON decoder as well (be aware that it can be very slow for large and deeply nested objects). You can get it from the FEX and then edit the lines where unicode objects are parsed.
  2 Kommentare
Elena Barbieri
Elena Barbieri am 6 Jul. 2022
Thank you so much! Your JSON decoder works very well and it is perfect for my needs!
Rik
Rik am 6 Jul. 2022
You're very much welcome.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Produkte


Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by