필터 지우기
필터 지우기

jsonencode not encoding entire large structure data

조회 수: 23 (최근 30일)
Pete sherer
Pete sherer 2024년 3월 22일
댓글: Walter Roberson 2024년 8월 16일 20:49
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.
  댓글 수: 1
Walter Roberson
Walter Roberson 2024년 8월 16일 20:49
I have a vague memory that possibly json encoding is limited to 2 Gb ??

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 JSON Format에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by