I want to GET
some json data from a server. I do this using:
UPDATE=$(curl -i -H "Accept: application/json" -H "Content-Type: application/json" --cookie "${COOKIE_NAME}" "${1}/update/${DEVICE_NAME}");
Before this, the server is authenticated. The ${1}
is the server domain, ${DEVICE_NAME}
is the name of the device requesting the update.
This returns a JSON as follows:
[{"_id":"54ff35887d8ef574029b9166","user":"54fe4313883bcec2c0ac0d64","__v":0,"created":"2015-03-10T18:18:48.023Z","status":"available","pbo_udid":"lemaker","installation_script":"","description":"Prints hello world to console","package_name":"helloworld_1.0-1.deb","name":"Hello World V1"}]
I want to now do 2 things:
- Make sure data is returned (if no update is available, the server returns
[]
- Extract data, for instance
package_name
How do I do these in Linux bash script?