Format output from jsonencode to make it more human readable

22 vues (au cours des 30 derniers jours)
Sonoma Rich
Sonoma Rich le 13 Avr 2017
Commenté : Payam Razavi le 8 Déc 2020
Can someone provide an example to format the output from jsonencode to make it more human readable. I.E. add carriage returns and indentations.
  1 commentaire
Swathik Kurella Janardhan
Swathik Kurella Janardhan le 20 Avr 2017
Modifié(e) : Swathik Kurella Janardhan le 20 Avr 2017
I am sorry that I didn't understand the question clearly. Can you elaborate on your question? You can refer to the jsonencode doc for more examples.

Connectez-vous pour commenter.

Réponses (1)

jcbyts
jcbyts le 8 Jan 2019
There might be a more efficient way to do this, but this worked well for me.
str = jsonencode(str);
str = strrep(str, ',', sprintf(',\r'));
str = strrep(str, '[{', sprintf('[\r{\r'));
str = strrep(str, '}]', sprintf('\r}\r]'));
  1 commentaire
Payam Razavi
Payam Razavi le 8 Déc 2020
Thanks! it worked for me with the following modification:
str = strrep(str, ',"', sprintf(',\r"'));

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by