Q:

How to parse with Bash script? (platform MIPS)?

$ curl -LNs "http://urladrescom/content.json" > content.json

content.json
{
   "k":[
      {
         "i":1,
         "n":"NAME 1",
         "p":[
            {
               "b":"Event 1",
               "c":"00:00",
               "d":"03:00"
            },
            {
               "b":"Event 2",
               "c":"23:00",
               "d":"00:00"
            }
         ]
      },
      {
         "i":2,
         "n":"NAME 2",
         "p":[
            {
               "b":"Event 1",
               "c":"07:15",
               "d":"09:15"
            },
            {
               "b":"Event 2",
               "c":"22:00",
               "d":"23:15"
            },
            {
               "b":"Event 3",
               "c":"23:15",
               "d":"02:30"
            }
         ]
      },
      {
         "i":3,
         "n":"NAME 3",
         "p":[
            {
               "b":"Event 1",
               "c":"07:15",
               "d":"09:15"
            },
            {
               "b":"Event 2",
               "c":"22:00",
               "d":"23:15"
            },
            {
               "b":"Event 3",
               "c":"23:15",
               "d":"02:30"
            }
         ]
      }
   ]
}

I want to get the content in "NAME 2" under Event 1,2,3 with a Bash script (grep, awk, sed, etc..) (or Python in a Bash script cmd).
I want print result :
NAME 2 \ Event 1 \ 07:15 \ 09:15
NAME 2 \ Event 2 \ 22:00 \ 23:15
NAME 2 \ Event 3 \ 23:15 \ 02:30

A:

You can use this Python to do what you want:
$ cat parse.py
#!/bin/python

import json
#from pprint import pprint

with open('content.json') as f:
  data = json.load(f)

for dict in data["k"]:
  if (dict["n"] == "NAME 2"):
    for elem in dict["p"]:
      print(dict["n"] + ' \\ ' + elem["b"] + ' \\ ' + elem["c"] + ' \\ ' + elem["d"])

Example
$ ./parse.py
NAME 2 \ Event 1 \ 07:15 \ 09:15
NAME 2 \ Event 2 \ 22:00 \ 23:15
NAME 2 \ Event 3 \ 23:15 \ 02:30

