Skip to content

ssullivan/json-schema-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-schema-explorer

A small command line utility to understand the fields, and datatypes in a JSON document.

Requirements

  • JDK >= 17
  • Maven

Build

This project creates an executable fat JAR file using the spring-boot-maven-plugin. The JAR will contain the dependencies necessary for execution.

mvn clean install

CLI

Usage: json-analyze -i=<file>
  -i, --input-file=<file>   The JSON file to analyze

Examples

Example1: JSON Object

cat <<EOF >example.json
{
  "version": 1,
  "product": {
    "name": "Example",
    "sizes": [
      {"size" : 1 }
    ],
    "weight": 1.5,
    "enabled": true
  }
}
EOF
java -jar json-schema-explorer-<version>.jar -i example.json

would produce the following output

{
  "product.enabled" : "boolean",
  "product.name" : "string",
  "product.weight" : "float",
  "sizes" : [ {
    "size" : "integer"
  } ],
  "version" : "integer"
}

Example2: JSON Array

cat <<EOF >example.json
[{
  "version": 1,
  "product": {
    "name": "Example",
    "sizes": [
      {"size" : 1 }
    ],
    "weight": 1.5,
    "enabled": true
  }
}]
EOF
java -jar json-schema-explorer-<version>.jar -i example.json

would produce the following output

[ {
  "product.enabled" : "boolean",
  "product.name" : "string",
  "product.weight" : "float",
  "sizes" : [ {
    "size" : "integer"
  } ],
  "version" : "integer"
} ]

Example3: Arrays of Arrays

cat <<EOF >example.json
[
  [1],
  [0.5],
  [true, false],
  ["string"],
  []
]
EOF

would produce the following output

[ [ "integer" ], [ "float" ], [ "boolean" ], [ "string" ], [ ] ]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages