Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten JSON #58

Open
thombashi opened this issue Nov 20, 2018 · 2 comments
Open

Flatten JSON #58

thombashi opened this issue Nov 20, 2018 · 2 comments
Assignees

Comments

@thombashi
Copy link
Owner

thombashi commented Nov 20, 2018

Flatten JSON which has JSON schema format currently not supported before converting.

Poll: #89

@thombashi thombashi self-assigned this Nov 20, 2018
@irgeek
Copy link

irgeek commented Sep 19, 2019

I do this by pre-processing my files with jq. Give the following:

flatten.json:

[
  {
    "a": {
      "b": 1,
      "c": 2
    }
  },
  {
    "a": {
      "b": 3,
      "c": 4
    }
  }
]

flatten.jq:

map([ leaf_paths as $path | { key: $path|join("."), value: getpath($path) } ]|from_entries)

the command jq -f flatten.jq flatten.json will produce the following output:

[
  {
    "a.b": 1,
    "a.c": 2
  },
  {
    "a.b": 3,
    "a.c": 4
  }
]

@thombashi
Copy link
Owner Author

#89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants