4

My test json file is as follows:

{
   "server":"xxx",
   "cert":"line1\nline2",
   "security/path": "/var/log/systems.log"
}

I would like to filter by key security/path, and below commands all don't work.

jq .security/path test.json
jq: error: path/0 is not defined at <top-level>, line 1:
.security/path
jq: 1 compile error

jq '.security/path' test.json has same result.

1 Answer 1

7

From Basic filters:

Object Identifier-Index:

...

If the key contains special characters or starts with a digit, you need to surround it with double quotes like this: ."foo$", or else .["foo$"]

....

So,

$ jq '."security/path"' test.json
"/var/log/systems.log"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.