linux - pipe array of json objects as a map of single post, using curl -
i have 2 nodes having same rest+json api ( not jsonapi.org btw )
one of them has many products in /products other has [] in /products
i want pipe products of 1 node ( say: http://localhost:9080/products
) other 1 ( http://localhost:8080/products
)
operation must happen on command line
this should solved problem ?
i think so, not know yet , have not find solution yet...
what experimented work , found ugly
for f in $( curl http://localhost:9080/products | jq -c '.[]' | sed -e 's/ /\\_/g' ); echo $f | sed -e 's/\\_//g' | curl -i -h content-type:application/json http://localhost:8080/products --data @-; done
the above uses jq json parser
curl http://localhost:9080/products | jq -c '.[]'
emits each products of collection
the ugly sed
hack meant tackle label fields
"label":"what favorite color?"
it job on small set of products, , still i'm not happy it
what did miss ?
what expect of response
- should perform "fast" above 1 ( i'm rubyist )
- should not longer, in chars, above 1 or should clearer
Comments
Post a Comment