3 ms·
>TEMPFILE=`mktemp`; curl -s <REQUEST> >$TEMPFILE; python -c "import json; f = open('$TEMPFILE', 'r'); d = json.load(f); <json processing logic and print stateme
by vips7L 7y ago
>TEMPFILE=`mktemp`; curl -s <REQUEST> >$TEMPFILE; python -c "import json; f = open('$TEMPFILE', 'r'); d = json.load(f); <json processing logic and print statement>; f.close()"
This is painful. In powershell this is built in and as easy as iwr url/to/json | convertfrom-json | other logic
- zomglings 7y agoInteresting, looks like Linux users can also try out Powershell now: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-6 https://docs.microsoft.com/en-us/powershell/scripting/instal... It's a beefy package, though. Packaged in a docker image on top of alpine:3.10.3 following their installation instructions for alpine: https://gist.github.com/nkashy1/643e7a263054c02e2caceb3912f82f20 https://gist.github.com/nkashy1/643e7a263054c02e2caceb3912f8... The image comes in at 178 MB. alpine:3.10.3 is 5.5 MB. An alpine image in which you add bash, bash-doc, and bash-completion clocks in at 13 MB. Sounds really powerful for personal use, but not an ideal tool for production use (e.g. when you need to spin up a pod on a Kubernetes cluster to debug an issue in production). Will definitely try it out.
- vips7L 7y agoProbably because it has to include the entire CLR/.net framework. I suppose that is a concern, but I doubt I'll ever be doing k8s or docker in my career anytime soon.
- deleted 7y ago[deleted]
- benibela 7y agoFor similar pipelines I build Xidel (http://www.videlibri.de/xidel.html http://www.videlibri.de/xidel.html) xidel url -e 'logic' and one such xidel call is enough regardless, if the url returns json, xml or html.