Iteratively posting via cURL set of Json records in bash -
i have set of json records in file. post iteratively. example file "jsondata.dat" contains following json records
{ "json_records":[ { "name": "name_1", "mark": "mark_1" }, { "name": "name_2", "mark": "mark_2" } ] }
i post each json record i.e.
{ "name": "name_x", "mark": "mark_x" }
in separate curl post. how achieve in bash?
i use jq
pipe each record single line, read output while
loop pass curl
.
jq -c '.json_records[]' | while ifs= read -r rec; curl -x post -d"$rec" "$url" done
Comments
Post a Comment