我正在尝试将普通的 json 字符串转换为新行分隔的 json 格式(ndjson)。我发现下面的 unix 命令可以执行相同的操作。
猫 test.json | jq -c '.[]' > testNDJSON.json
我需要一个等效的 java 功能。
PFB 我要转换为 ndjson 的 json 字符串。
[{"id":1266052,"date1":"2020 年 6 月 2 日 12:00:00 AM","userId":721187,"externalSource":"B","completedCardioActivityDataVOList":[],"completedStrengthActivityVO": {"activityId":110303,"lfCodeId":1,"intensity":2,"duration":180,"recommendedValueArray":"4","lfCalories":18.0,"createdAt":"2017 年 9 月 25 日 1: 25:16 PM","updatedAt":"Sep 25, 2017 1:25:16 PM"},"completedStrengthActivityDataVOList":[{"id":630060,"setNumber":1,"actualRepetitions":30,"actualResistanceEn ":60.0,"actualResistanceMt":27.215542}]},{"id":1339904,"date1":"2020 年 6 月 2 日 12:00:00 AM","userId":721187,"externalSource":"B","guid":"17b86829-0b38-4a95-a3a3-6dc006b3a979","completedCardioActivityVO":{"activityId":1,"workoutId":1},"completedCardioActivityDataVOList":[{"id" :8058043,"cardioParameterId":7,"targetCardioParameterValueMt":0.0,"targetCardioParameterValueEn":0.0,"actualCardioParameterValueMt":25.6,"actualCardioParameterValueEn":25.6},{"id":8058044,"cardioParameterId":5,"targetCardioParameterValueMt" :0.0,"targetCardioParameterValueEn":0.0,"actualCardioParameterValueMt":139.0,"actualCardioParameterValueEn":139.0},{"id":8058045,"cardioParameterId":13,"targetCardioParameterValueMt":0.0,"targetCardioParameterValueEn":0.0,"actualCardioParameterValueMt":88.0,"actualCardioParameterValueEn":88.0},{"id":8058046,"cardioParameterId":12,"targetCardioParameterValueMt":0.0,"targetCardioParameterValueEn":0.0,"actualCardioParameterValueMt":0.0,"actualCardioParameterValueEn": 0.0},{"id":8058047,"cardioParameterId":25,"targetCardioParameterValueMt":0.0,"targetCardioParameterValueEn":0.0,"actualCardioParameterValueMt":0.0,"actualCardioParameterValueEn":0.0},{"id":8058048,"cardioParameterId ":24,"targetCardioParameterValueMt":0.0,"targetCardioParameterValueEn":0.0,"actualCardioParameterValueMt":0.0,"actualCardioParameterValueEn":0.0},{"id":8058049,"heartParameterId":6,"targetCardioParameterValueMt":0.0,"targetCardioParameterValueEn":0.0,"actualCardioParameterValueMt":27.358849,"actualCardioParameterValueEn":17.0},{"id":8058050,"cardioParameterId":14,"targetCardioParameterValueMt":0.0," targetCardioParameterValueEn":0.0,"actualCardioParameterValueMt":5.365553,"actualCardioParameterValueEn":3.334},{"id":8058051,"cardioParameterId":4,"targetCardioParameterValueMt":0.0,"targetCardioParameterValueEn":0.0,"actualCardioParameterValueMt":2.2880044," actualCardioParameterValueEn":1.4217},{"id":8058052,"cardioParameterId":21,"targetCardioParameterValueMt":0.0,"targetCardioParameterValueEn":0.0,"actualCardioParameterValueMt":30.7848,"actualCardioParameterValueEn":101.0}],"completedStrengthActivityDataVOList":[]}]