fork(1) download
  1. #!/bin/bash
  2. perl -0777 -pe '
  3. s/\{(\s*(?:[0-9.]+|false|true|null|"[^"]*")\s*[,}])/[$1/g;
  4. s/([,[]\s*(?:[0-9.]+|false|true|null|"[^"]*")\s*)\}/$1]/g'
Success #stdin #stdout 0.01s 5472KB
stdin
{"hello": 1,
"grid": {"C1", "D1", "E1", "C2", "D2", "E2", "F2", "B3", "C3", "D3", "E3", "F3", "B4", "C4", "D4", "E4", "F4", "C5", "D5", "E5", "F5", "C6", "D6", "E6"},
"drig": {
  12, 34.56, true, false, null
},
"gird": {"foo"},
"BUG: quoted string with braces should not be modified, but still is": "{123, \"failure\", null}",
"something": "else"}
stdout
{"hello": 1,
"grid": ["C1", "D1", "E1", "C2", "D2", "E2", "F2", "B3", "C3", "D3", "E3", "F3", "B4", "C4", "D4", "E4", "F4", "C5", "D5", "E5", "F5", "C6", "D6", "E6"],
"drig": [
  12, 34.56, true, false, null
],
"gird": ["foo"],
"BUG: quoted string with braces should not be modified, but still is": "[123, \"failure\", null]",
"something": "else"}