how to solve extra text error when reading json files?
Afficher commentaires plus anciens
I am trying to read a json file from an arduino board in matlab with the following script:
% fileName = 'test1.json'; % filename in JSON extension
% str = fileread(fileName); % dedicated for reading files as text
% data = jsondecode(str); % Using the jsondecode function to parse JSON from string
but I get the following error:
Error using jsondecode JSON syntax error at line 1, column 79 (character 79): additional text. Error in read_json (line 4) data = jsondecode(str); % Using the jsondecode function to parse JSON from a string
I imagine it must be something with the quotes, commas or brackets...
I need to extract the acceleration values to use them in matlab later (acc_x, acc_y, and acc_z). The json fille is:
{"acc_x": 0.24, "acc_y": 0.78, "acc_z": 0.46, "Timestamp": 1691078254.4053023},
{"acc_x": 0.27, "acc_y": 0.78, "acc_z": 0.47, "Timestamp": 1691078254.4153075},
{"acc_x": 0.29, "acc_y": 0.78, "acc_z": 0.5, "Timestamp": 1691078254.43097},
{"gy_x": -35.89, "gy_y": 3.78, "gy_z": 14.4, "Timestamp": 1691078254.43097},
{"acc_x": 0.32, "acc_y": 0.78, "acc_z": 0.47, "Timestamp": 1691078254.4409742},
{"gy_x": -33.39, "gy_y": 2.62, "gy_z": 13.98, "Timestamp": 1691078254.4409742},
{"acc_x": 0.32, "acc_y": 0.78, "acc_z": 0.44, "Timestamp": 1691078254.4409742},
{"gy_x": -29.79, "gy_y": 1.83, "gy_z": 8.79, "Timestamp": 1691078254.4409742},
{"acc_x": 0.27, "acc_y": 0.8, "acc_z": 0.41, "Timestamp": 1691078254.456637},
{"gy_x": -25.57, "gy_y": -0.37, "gy_z": 7.51, "Timestamp": 1691078254.456637},
{"acc_x": 0.25, "acc_y": 0.82, "acc_z": 0.44, "Timestamp": 1691078254.4666882},
{"gy_x": -25.57, "gy_y": -1.65, "gy_z": 8.85, "Timestamp": 1691078254.4767776},
{"acc_x": 0.22, "acc_y": 0.82, "acc_z": 0.46, "Timestamp": 1691078254.4767776},
{"gy_x": -28.81, "gy_y": -0.31, "gy_z": 11.29, "Timestamp": 1691078254.4767776},
{"acc_x": 0.23, "acc_y": 0.82, "acc_z": 0.46, "Timestamp": 1691078254.486785},
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!