jsonencode not encoding entire large structure data
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi
I have a large table converting to structure type and then use the jsonencode to encode the data.
However I realized that not all data has been converted to json, since the ending was not "]" or "}".
Is there a fail-safe way to convert large table to json?
Thanks,
1 Kommentar
Rik
am 23 Mär. 2024
Can you attach the data you are trying to convert? Or can you generate a variable with fake/random data that reproduces this?
It isn't hard to write a JSON encoder, so you could also go that route. There are many edge cases, but if you write your own, you might not need to implement everything.
Antworten (1)
Rushikesh
am 16 Aug. 2024
I can see that you have a large table converted to structure type and wants to encode it in JSON. Since the converted data is not ending with “]” or “}”, I assume encoding process was interrupted or failed to process the entire data set.
It would be easier to answer if you could provide relevant example data, size of table or structure.
However, you can try following generalized steps based on above interpretation to resolve the error.
1. Split the Data
If your data is too large, you can try splitting your data into smaller chunks, i.e. smaller tables or structures, followed by encoding each separately and then combining JSON strings.
You can refer to discussion of similar question given below to get more idea about data splitting.
2. Check Data Types
There are several limitations when using “jsonencode” function inside MATLAB. You can refer to following documentation on these limitations and ensure that all the data types within your table are supported by “jsonencode”. Unsupported data types might cause the encoding process to terminate prematurely.
If issue seems like memory limilation then try increasing Java Heap Memory in MATLAB preferences.
Please let me know if this helps.
1 Kommentar
Walter Roberson
am 16 Aug. 2024
I have a vague memory that possibly json encoding is limited to 2 Gb ??
Siehe auch
Kategorien
Mehr zu JSON Format finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!