is there any way to append multiple json files into single files

조회 수: 29 (최근 30일)
Anuj
Anuj 2024년 11월 6일 6:41
댓글: Anuj 2024년 11월 6일 7:45
I have generated multiple JSON files and want to append these files into one file. Is there a way to merge multiple JSON files into a single file in MATLAB?

채택된 답변

Gayatri
Gayatri 2024년 11월 6일 6:53
Hi Anuj,
You can use below script to append multiple JSON files into single file.
%Read contents of File 1
st1 = fileread('label_data_1.json');
%Read contents of File 2
st2 = fileread('label_data_2.json');
%Open a new JSON file in text mode
[fid,msg] = fopen('combined.json','wt');
%Write contents of File 1 and File 2 in the new file
fprintf(fid,'%s\n%s',st1,st2);
%Close the open file
fclose(fid);
Here "combined.json" will be the desired JSON file. 
Please refer the below documentation for fprintf : https://www.mathworks.com/help/matlab/ref/fprintf.html

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by