how to add json object to json file using shell script

后端 未结 2 1458
情深已故
情深已故 2021-01-01 14:57

json file as follows:

{\"name\" :\"sam\",
\"age\":23,
\"designation\":\"doctor\"}

now i want to add another json object {\"location\":\"can

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 15:34

    sed -i '$s/}/,\n"location":"canada"}/' sample.json
    

    Result:

    {"name" :"sam",
    "age":23,
    "designation":"doctor",
    "location":"canada"}
    

提交回复
热议问题