Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 9v0067255515000000000597

Nested JSON Flattener

Transform a deeply nested JSON structure into a flattened key-value format where each path is represented by dot notation

Start file
{
  "company": {
    "details": {
      "name": "TechCorp",
      "founded": 1995,
      "isPublic": true
    },
    "locations": {
      "headquarters": {
        "address": {
          "street": "123 Innovation Way",
          "unit": "4B",
          "city": "San Francisco",
          "state": "CA",
          "zip": "94105"
        },
        "coordinates": {
          "lat": 37.7749,
          "lng": -122.4194
        }
      },
      "branches": {
        "europe": {
          "primary": {
            "city": "London",
            "employees": 250,
            "opened": "2020-01-15"
          },
          "secondary": {
            "city": "Berlin",
            "employees": 120,
            "opened": "2021-03-01"
          }
        },
        "asia": {
          "primary": {
            "city": "Tokyo",
            "employees": 180,
            "opened": "2019-11-30"
          }
        }
      }
    },
    "metrics": {
      "financial": {
        "revenue": {
          "2021": 1500000,
          "2022": 2200000,
          "2023": 3100000
        },
        "expenses": {
          "2021": 1200000,
          "2022": 1800000,
          "2023": 2500000
        }
      },
      "performance": {
        "goals": {
          "q1": 85,
          "q2": 90,
          "q3": 88,
          "q4": 92
        }
      }
    }
  }
}
End file
company.details.name=TechCorp
company.details.founded=1995
company.details.isPublic=true
company.locations.headquarters.address.street=123 Innovation Way
company.locations.headquarters.address.unit=4B
company.locations.headquarters.address.city=San Francisco
company.locations.headquarters.address.state=CA
company.locations.headquarters.address.zip=94105
company.locations.headquarters.coordinates.lat=37.7749
company.locations.headquarters.coordinates.lng=-122.4194
company.locations.branches.europe.primary.city=London
company.locations.branches.europe.primary.employees=250
company.locations.branches.europe.primary.opened=2020-01-15
company.locations.branches.europe.secondary.city=Berlin
company.locations.branches.europe.secondary.employees=120
company.locations.branches.europe.secondary.opened=2021-03-01
company.locations.branches.asia.primary.city=Tokyo
company.locations.branches.asia.primary.employees=180
company.locations.branches.asia.primary.opened=2019-11-30
company.metrics.financial.revenue.2021=1500000
company.metrics.financial.revenue.2022=2200000
company.metrics.financial.revenue.2023=3100000
company.metrics.financial.expenses.2021=1200000
company.metrics.financial.expenses.2022=1800000
company.metrics.financial.expenses.2023=2500000
company.metrics.performance.goals.q1=85
company.metrics.performance.goals.q2=90
company.metrics.performance.goals.q3=88
company.metrics.performance.goals.q4=92

View Diff

1,67c1,29
< {
<   "company": {
<     "details": {
<       "name": "TechCorp",
<       "founded": 1995,
<       "isPublic": true
<     },
<     "locations": {
<       "headquarters": {
<         "address": {
<           "street": "123 Innovation Way",
<           "unit": "4B",
<           "city": "San Francisco",
<           "state": "CA",
<           "zip": "94105"
<         },
<         "coordinates": {
<           "lat": 37.7749,
<           "lng": -122.4194
<         }
<       },
<       "branches": {
<         "europe": {
<           "primary": {
<             "city": "London",
<             "employees": 250,
<             "opened": "2020-01-15"
<           },
<           "secondary": {
<             "city": "Berlin",
<             "employees": 120,
<             "opened": "2021-03-01"
<           }
<         },
<         "asia": {
<           "primary": {
<             "city": "Tokyo",
<             "employees": 180,
<             "opened": "2019-11-30"
<           }
<         }
<       }
<     },
<     "metrics": {
<       "financial": {
<         "revenue": {
<           "2021": 1500000,
<           "2022": 2200000,
<           "2023": 3100000
<         },
<         "expenses": {
<           "2021": 1200000,
<           "2022": 1800000,
<           "2023": 2500000
<         }
<       },
<       "performance": {
<         "goals": {
<           "q1": 85,
<           "q2": 90,
<           "q3": 88,
<           "q4": 92
<         }
<       }
<     }
<   }
< }
---
> company.details.name=TechCorp
> company.details.founded=1995
> company.details.isPublic=true
> company.locations.headquarters.address.street=123 Innovation Way
> company.locations.headquarters.address.unit=4B
> company.locations.headquarters.address.city=San Francisco
> company.locations.headquarters.address.state=CA
> company.locations.headquarters.address.zip=94105
> company.locations.headquarters.coordinates.lat=37.7749
> company.locations.headquarters.coordinates.lng=-122.4194
> company.locations.branches.europe.primary.city=London
> company.locations.branches.europe.primary.employees=250
> company.locations.branches.europe.primary.opened=2020-01-15
> company.locations.branches.europe.secondary.city=Berlin
> company.locations.branches.europe.secondary.employees=120
> company.locations.branches.europe.secondary.opened=2021-03-01
> company.locations.branches.asia.primary.city=Tokyo
> company.locations.branches.asia.primary.employees=180
> company.locations.branches.asia.primary.opened=2019-11-30
> company.metrics.financial.revenue.2021=1500000
> company.metrics.financial.revenue.2022=2200000
> company.metrics.financial.revenue.2023=3100000
> company.metrics.financial.expenses.2021=1200000
> company.metrics.financial.expenses.2022=1800000
> company.metrics.financial.expenses.2023=2500000
> company.metrics.performance.goals.q1=85
> company.metrics.performance.goals.q2=90
> company.metrics.performance.goals.q3=88
> company.metrics.performance.goals.q4=92

Solutions by @MCHRI120_ford:

Unlock 2 remaining solutions by signing in and submitting your own entry
Created by: @pacuna

10 active golfers, 18 entries

Solutions by @MCHRI120_ford:
56
#3 - Christensen, Scott (S.C.) / @MCHRI120_ford

11/04/2024 at 03:29PM

68
#>5 - Christensen, Scott (S.C.) / @MCHRI120_ford

11/04/2024 at 03:23PM