Collecting multiple .json objects in one .json file?
12 次查看(过去 30 天)
显示 更早的评论
Hello everyone, I'm developing a deep learning Mask R-CNN training.
I have labeled images through imageLabeler and I got the annotations as gTruth file. Then I have converted these files in .json objects using the following code :
annotationsFileName='gTruth_coco.json';
exportGroundTruthToJSON(gTruth,annotationsFileName,'COCO',true)
Now, the problem is I have to collect these .json files in one .json file.
How can I do that?
Many thanks for your attention and your kind help.
0 个评论
回答(1 个)
Prince Kumar
2021-11-17
编辑:Prince Kumar
2021-11-19
You can open the json files and append them one after another. Following is how you can achieve it.
st1 = fileread('data/label_data_1.json');
st2 = fileread('data/label_data_2.json');
[fid,msg] = fopen('combined.json','wt');
fprintf(fid,'%s\n%s',st1,st2);
fclose(fid);
Here 'combined.json' will be your desired json file.
To perform the above operation on Linux system without MATLAB, you may run the following commands in terminal
touch combined.json
cat data/label_data_1.json >> combined.json
cat data/label_data_2.json >> combined.json
0 个评论
另请参阅
类别
在 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!