https://github.com/fgeller/json-structure
converts a json value to one that describes its structure
https://github.com/fgeller/json-structure
cli golang json json-schema
Last synced: about 1 month ago
JSON representation
converts a json value to one that describes its structure
- Host: GitHub
- URL: https://github.com/fgeller/json-structure
- Owner: fgeller
- Created: 2022-09-11T17:34:21.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-20T15:22:35.000Z (over 3 years ago)
- Last Synced: 2025-06-16T07:08:13.568Z (about 1 year ago)
- Topics: cli, golang, json, json-schema
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# json-structure
Reads a JSON value from stdin and converts it to a JSON value that describes the structure of the original value.
## Example
```
% json-structure -help
Usage of json-structure:
-flatten
flatten schemata in arrays and combine objects
-schema
output a json schema
% cat sample.json
{
"productId": 1,
"productName": "A green door",
"price": 12.50,
"tags": [ "home", "green" ]
}
% cat sample.json | json-structure | jq
{
"price": "number",
"productId": "number",
"productName": "string",
"tags": [
"string",
"string"
]
}
% cat sample.json | json-structure -flatten | jq
{
"price": "number",
"productId": "number",
"productName": "string",
"tags": [
"string"
]
}
% cat sample.json | json-structure -flatten -schema | jq
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"price": {
"type": "number"
},
"productId": {
"type": "number"
},
"productName": {
"type": "string"
},
"tags": {
"type": "array",
"contains": {
"type": "string"
}
}
}
}
```
## Installation
```
% go install github.com/fgeller/json-structure@latest
```