jq with curl fails if select filter is used -
i'm piping curl output jq: https://stedolan.github.io/jq/ , works great until try use select filter.
this filter works fine when in online tool: https://jqplay.org/ , in command line experiments after having downloaded file.
this issue occurs when try directly pipe curl output jq.
this fails:
i71178@slcits-l2222:~/next-gen/mongodb$ curl 'http://fhirtest.uhn.ca/basedstu3/patient?_format=json&_count=50&_pretty=false&_summary=data' | jq-linux64 --unbuffered -r -c '.link[] | select(.relation == next) | .url' | head -3 jq: error: next/0 not defined @ <top-level>, line 1: .link[] | select(.relation == next) | .url jq: 1 compile error % total % received % xferd average speed time time time current dload upload total spent left speed 100 2421 0 2421 0 0 2413 0 --:--:-- 0:00:01 --:--:-- 2413 curl: (23) failed writing body (1675 != 2736) i71178@slcits-l2222:~/next-gen/mongodb$
this works fine:
i71178@slcits-l2222:~/next-gen/mongodb$ curl 'http://fhirtest.uhn.ca/basedstu3/patient?_format=json&_count=50&_pretty=false&_summary=data' | jq-linux64 --unbuffered -r -c '.link[] | .url' | head -3 % total % received % xferd average speed time time time current dload upload total spent left speed 100 46801 0 46801 0 0 66256 0 --:--:-- --:--:-- --:--:-- 66290 http://fhirtest.uhn.ca/basedstu3/patient?_count=50&_format=json&_pretty=false&_summary=data http://fhirtest.uhn.ca/basedstu3?_getpages=e73ba3b4-cc7e-4028-8679-b5da1f9cbdd1&_getpagesoffset=50&_count=50&_format=json&_bundletype=searchset i71178@slcits-l2222:~/next-gen/mongodb$
for context, being pipes select filter:
i71178@slcits-l2222:~/next-gen/mongodb$ curl 'http://fhirtest.uhn.ca/basedstu3/patient?_format=json&_count=50&_pretty=false&_summary=data' | jq-linux64 --unbuffered -r -c '.link[]' | head -3 % total % received % xferd average speed time time time current dload upload total spent left speed 100 46801 0 46801 0 0 64411 0 --:--:-- --:--:-- --:--:-- 64375 {"relation":"self","url":"http://fhirtest.uhn.ca/basedstu3/patient?_count=50&_format=json&_pretty=false&_summary=data"} {"relation":"next","url":"http://fhirtest.uhn.ca/basedstu3?_getpages=00952912-c9ab-47ca-826c-200bddffe617&_getpagesoffset=50&_count=50&_format=json&_bundletype=searchset"} i71178@slcits-l2222:~/next-gen/mongodb$
i appreciate here.
thanks!
the problem evidently select
filter:
select(.relation == next)
i think meant:
select(.relation == "next")
safer be:
select(.relation? == "next")
Comments
Post a Comment