Just flatten it!
json-flattener streams and flattens a JSON content into a single-leveled, dot-separated output, instead of having structured properties.
Given the following JSON:
{
"name": "User",
"detail": {
"address": "Test Avenue",
"zip": 12345
}
}
The flattened version is as follows:
{
"name": "User",
"detail.address": "Test Avenue",
"detail.zip": 12345
}
There are two modules within this project:
A command-line interface for reading JSON content and flattening. It should be used if you want to use in your command line using stdin (eg.: piping a content into it).
If you want to include as a library of your application. Clone the project and run mvn install
so you should be able to see it in your local repo.
Just download the dist folder HERE and, in shell, create an alias to the download binaries, for example:
- Download the dist folder as zip
- Unpack and cd into it
alias jf=$PWD/bin/json-flattener-1.0
Assuming the last steps above were followed, you need now to stream the data into the app. Eg.:
cat content.json | jf
will print the flattened version of JSON into stout
cat content.json | jf > flattened.json
will generate a file containing the flattened version of content.json
- It doesn't support arrays.
- Java 8
- Unix-compatible system
In order to build locally, you need to have maven 3.x installed, as well as Java 8.
Just clone this repo and run:
mvn package
Fork and open a PR.
It is under MIT license, which can be checked here
- Include support for file input (instead of only piping into the program)
- Include support for arrays
- Add libraries to maven-central
- Add build-pipeline
- Create deb packages/Tap formulae/etc