I have an IP camera with armv5tejl architecture. There I have busybox. I have to be able to parse JSON responses from curl. The problem is that I don't have programs like:
jq, jshon, jsawk...
It is hard to instal them for this architecture. I have to find some shell script which can parse JSON object and JSON array.
If it is possible to find this script, please, show me that script
-
what about perl?– Jeff Schaller ♦Jul 27, 2016 at 17:28
-
Don't have neither perl nor python. I have to find some solution with awk, sed, grep and so on..– OleksandrJul 27, 2016 at 17:30
-
2jq should not be hard to compile from source, it only needs bison and flex– grochmalJul 27, 2016 at 19:32
2 Answers
-
Yes. Thank you for help. I have found json.awk just several minutes ago) Jul 27, 2016 at 20:16
-
As grochmal said. There is jq which is pretty good but I couldn't compile it.
Also we can just use JSON.awk to parse json (is not very convenient but works).
Example:
echo -e jsonFile | awk -f JSON.awk
To get necessary keys and values we can grep output. Example (parse json response with google drive folders to find all ids of folders):
echo -e jsonResponse | awk -f JSON.awk | egrep '\["items",[0-9]+,"id"\]'