LoginSignup
2

More than 5 years have passed since last update.

jsonの整形

Posted at
% ls  
sample.json
% cat sample.json
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "pref": "富山県", "city1": "下新川郡", "city2": "朝日町"}, "geometry": { "type": "Polygon", "coordinates":[ [ [ 136.111111, 36.111111 ], [ 136.222222, 36.222222 ]]] }},
{ "type": "Feature", "properties": { "pref": "富山県", "city1": "氷見市", "city2": ""}, "geometry": { "type": "Polygon", "coordinates":[ [ [ 136.333333, 36.333333 ], [ 136.444444, 36.444444 ]]] }},
{ "type": "Feature", "properties": { "pref": "富山県", "city1": "高岡市", "city2": ""}, "geometry": { "type": "Polygon", "coordinates":[ [ [ 136.555555, 36.555555 ], [ 138.666666, 36.666666 ]]] }}
]
}
% brew install jq
% cat sample.json | jq '.'
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "pref": "富山県",
        "city1": "下新川郡",
        "city2": "朝日町"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              136.111111,
              36.111111
            ],
            [
              136.222222,
              36.222222
            ]
          ]
        ]
      }
    },

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2