JSON decode extra character error

52 visualizzazioni (ultimi 30 giorni)
Paulo
Paulo il 2 Dic 2024 alle 13:41
Commentato: Sandeep Mishra il 2 Dic 2024 alle 13:48
I have tried using both of these scripts to decode json files into matlab structures.
filename='sample.json';
str=fileread(filename);
JSONstruc=jsondecode(str);
filename='sample.json';
fid=fopen(filename);
raw=fread(fid,inf);
str=char(raw');
fclose(fid);
JSONstruc=jsondecode(str);
Both versions work fine for one sample json file but I get the same error for a second json file
Error using jsondecode
JSON syntax error at line 2,column 1(character ____):extra text
I'm using Matlab R2023b.
  1 Commento
Sandeep Mishra
Sandeep Mishra il 2 Dic 2024 alle 13:48
Is the error occurring in just one specific file? If so, there might be an issue with that JSON file. Could you please share it for better analysis?

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by