Jq: Wie kann ich einen JSON analysieren, dessen Schlüssel mit einer numerischen Zeichenfolge beginnt

Erstellt am 23. Apr. 2014  ·  3Kommentare  ·  Quelle: stedolan/jq

Ich habe ein json-Like

{"2xx_count":10,"3xx_count":11}

aber ich bekomme Fehler wie folgt:

$ echo '{"2xx_count":10,"3xx_count":11}' | jq .2xx_count
error: syntax error, unexpected IDENT, expecting $end
.2xx_count
  ^^^^^^^^
1 compile error
support

Hilfreichster Kommentar

echo '{"2xx_count":10,"3xx_count":11}' | jq '.["2xx_count"]'

Alle 3 Kommentare

echo '{"2xx_count":10,"3xx_count":11}' | jq '.["2xx_count"]'

@lluchs danke!

@lluchs

Wie macht man das mit key_name als Variable? Beispielsweise

cat data.json | jq '.["$1"]' wobei $1 der erste Parameter ist ?

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen

Verwandte Themen

rokka-n picture rokka-n  ·  4Kommentare

tbelaire picture tbelaire  ·  4Kommentare

benjamin-bin-shen picture benjamin-bin-shen  ·  3Kommentare

ghost picture ghost  ·  4Kommentare

tischwa picture tischwa  ·  4Kommentare