jsonencode not encoding entire large structure data
23 次查看(过去 30 天)
显示 更早的评论
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 个评论
Rik
2024-3-23
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.
回答(1 个)
Rushikesh
2024-8-16,8:45
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 个评论
Walter Roberson
2024-8-16,20:49
I have a vague memory that possibly json encoding is limited to 2 Gb ??
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 JSON Format 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!