jsondecode: preserve original string

조회 수: 18 (최근 30일)
Elena Barbieri
Elena Barbieri 2022년 7월 5일
댓글: Rik 2022년 7월 6일
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!

채택된 답변

Rik
Rik 2022년 7월 6일
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
Elena Barbieri
Elena Barbieri 2022년 7월 6일
Thank you so much! Your JSON decoder works very well and it is perfect for my needs!
Rik
Rik 2022년 7월 6일
You're very much welcome.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 JSON Format에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by