I have a variable with an example JSON format, a mix of array and objects. I am trying to get the value for one of the objects in an array, without " or ,
Using only the basic grep command, for read-only servers. Please note that the server has only bash, doesn't have X code, and has no way to install jq or homebrew.
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
        [-e pattern] [-f file] [--binary-files=value] [--color=when]
        [--context[=num]] [--directories=action] [--label] [--line-buffered]
        [--null] [pattern] [file ...]
echo $exampleJSON
Output:
{
  "array": [
    {
       "ex1": 901,
       "ex2": 902,
       "ex3": 903,
       "ex4": 904,
       "ex5": 905,
       "ex6": 906,
    }
  ]
  "something_else": {
    "a1": 0
  }
}
The closest I have gotten is with echo $exampleJSON | grep -Eo '"ex3":.*?[^\\],"' which will output:
"ex3": 903,"
How can I clean up and extract 903, assuming the value can change, please advise!
