0

We are in need of formatting the JSON file using shell scripting.

INPUT

    {
  "version": ["sessionrestore",1], "windows": [{"tabs": [{"entries": [{"title": "news.ORF.at","docshellID": 298,"docIdentifier": 10062,"persist": true},{"title": "news.at","docshellID": 288,"docIdentifier": 00062,"persist": false}]}
    }
}

Expected Output

    {
"version": [
    "sessionrestore",1
  ],
  "windows": [
    {
      "tabs": [
        {
          "entries": [
            {title : news.ORF.at , docshellID : 298, docIdentifier : 10062 ,persist : true},
            {title: news.at,docshellID: 288,docIdentifier: 00062,persist: false}
            ]

        }
    }
} 

Can anyone help us to get the desired output using shell scripting? Please let me know if any additional information required on this

Chandru M
  • 133
  • 1
  • 7
  • It looks like you're trying to pretty-print valid JSON, which can be trivially done with, for example, [jq](https://stedolan.github.io/jq/). However, at the same time, you randomly remove quotes, turning it into invalid JSON, and the indentation seems pretty random, too... are these just oversights, or do you _really_ want exactly that format? – Benjamin W. Apr 11 '17 at 13:47
  • Actually, the input doesn't seem to be valid JSON either. – Benjamin W. Apr 11 '17 at 13:56
  • See this: http://stackoverflow.com/questions/352098/how-can-i-pretty-print-json – neric Apr 11 '17 at 15:54
  • @neric Thanks for the reference. Will look into it – Chandru M Apr 13 '17 at 08:07

0 Answers0