Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 527

Escape field name in jq that contains '@' and '-'? [duplicate]

$
0
0

Input JSON:

{"abc": {"@def-ghi": "value1","xyz": "value2"  }}

And I'm trying to get value for field @def-ghi.

➜ $?=0 ➤ echo '{"abc": {"@def-ghi": "value1", "xyz": "value2"}}' | jq '.abc.xyz'"value2"➜ $?=0 ➤ echo '{"abc": {"@def-ghi": "value1", "xyz": "value2"}}' | jq '.abc.@def-ghi'jq: error: syntax error, unexpected '-', expecting QQSTRING_START (Unix shell quoting issues?) at <top-level>, line 1:.abc.@def-ghijq: 1 compile error➜ $?=3 ➤

How to escape the field name properly?


Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>