I want to add an array to the "fields" How can I do that?
how to add a "fields" array?
fields=()
for f in NameData/*.json
do
Name= cat $f | jq -r '.[] | .Name'
Value= cat $f | jq -r '.[] | .Value'
fields+= #how?
'{
"name" : "'$Name'",
"value": "'$Value'"
},'
done
#output for fields
{
"name" : "Test"
"value" : "1"
},
{
"name" : "Test2"
"value" : "2"
},
...
Because next to post
function Hi(){
curl -H "Content-Type: application/json" -X POST -d \
'{
#how to array in fields //while?
"fields": [
{
"name": "Test",
"value":"'1'",
},
{
"name": "Test2",
"value":"'2'",
}
...
]
...
}}
How do I need to give more details? Can you help me? Thanks.
My files here (JSON) like I'm trying to get the name and value
xample.json
[
...
{
"folder" : "nobody",
"name": "1TS",
"value": "2",
...
}
]
example2.json
[
{
"name": "TST",
"value": "4.75",
...
}
]