0

I have the following Json file.

{
  "pagelen": 50,
  "values": [
    {
      "rm": "dev",
      "links": {
        "watchers": {
          "gre": "hello_world"
        },
        "url": [
          {
            "href": "test.com",
            "name": "http"
          },
          {
            "href": "ignore",
            "name": "ssh"
          }
        ],
    }
    "page": 1,
    "size": 10
}

I want to pass every url value to an for loop.

As I am now to shell scripting, I couldn't find the better way to do it.

every url value should be passed in the loop

how we can achieve this?

dubru
  • 142
  • 10
  • may help this json parse https://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools – daremachine Jun 12 '19 at 10:56
  • Look into `jq`, it is built for JSON parsing. Scripts for that become big and bug prone quickly. That being said, in your particular situation, `grep` and `cut` will do the trick nicely, since you want all of the href values anyway. – Nic3500 Jun 13 '19 at 00:44

0 Answers0