I know how to echo / add text to the end of a file:
echo "{ "fruit":"apple" , "amount":"10" }" >> file.txt
My question is how to add a object to the json file below:
the file – file.txt (empty):
{
"fruit": [
]
}
Expected result:
{
"fruit": [
{ "fruit":"apple" , "amount":"10" } #object to add
]
}
edis the standard text editor.Don’t know why you want to use bash for that, though, there are much better tools around!
Done.