N
N
Nikolay Baranenko2022-01-10 22:17:56
bash
Nikolay Baranenko, 2022-01-10 22:17:56

How to escape "-" when running jq utility?

i have json file

{
  "name": "view1",
  "version": "1.1.1",
  "target-dir": "/opt/project/spark-jobs/",
  "target-hosts": {
    "dev": ["host1", "host2"],
    "prod": ["host3", "host4"]
  }
}


from which you need to read the values ​​dev and prod in target-hosts using the jq utility, the

problem is that jq swears if you refer to the target-hosts name,

jq '.target-hosts' deploy.json

how to correctly refer to the name of the element with such a name?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xotkot, 2022-01-10
@drno-reg

jq '."target-hosts"' deploy.json

A
AVKor, 2022-01-10
@AVKor

jq '."target-hosts"' deploy.json

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question