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
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
Rushikesh 2024-8-16,8:45
Hello, @Pete sherer
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.

标签

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by