element has actually three children,
namely two space strings " " and the element. Indexing the
strings with .c yields an error, whereas indexing them with .c? just
yields nothing, allowing us to ignore the space.)
We can see the effects of that on a slightly simplified version of the
HTML:
"" +
" | 25 | 0x1819 | " +
" | 100 | 0x1864 | " +
" "
| fromxml | .. | select(.t? == "tr").c | [.[].c?[]] -->
[ "25", "0x1819"]
["100", "0x1864"]
To run this via the CLI:
jaq '.. | select(.t? == "tr").c | [.[].c?[]]' examples/cbor-examples.xhtml
We can create a series of tests as follows:
jaq '.. | select(.t? == "tr").c | [.[].c?[]] | @json "jc(\(.[0]), \(.[1][2:]));"' \
examples/cbor-examples.xhtml -r
I used exactly this command to create a draft for jaq's CBOR parsing
test suite.
AUTHOR
Michael Farber
SEE ALSO
jq(1)
JAQ(1)
|