0

I wanted to read the value of "roles" from the below json file (demo.json).

"A": {
  "User": "xyz",
  "Role": {
    "Role1": [
      "piolet"
    ],
    "Role2": [
      "driver"
    ],
    "Role3": [
      "technician"
    ]
  },
  "Id": "1",
}

I am using grep to read role ,but this command gives me only

{

My expected result is:

"Role1": [
  "piolet"
],
"Role2": [
  "driver"
],
"Role3": [
  "technician"
]

Please provide me some solution to do this ,please prefer some basic utility if possible.

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55

1 Answers1

0

You can use grep with -A n option to print N lines after matching lines. Like this.

grep "Role" -A 2 demo.json