{"id":13586973,"url":"https://github.com/trassmann/schermz","last_synced_at":"2025-04-07T18:35:23.184Z","repository":{"id":167732167,"uuid":"640529095","full_name":"trassmann/schermz","owner":"trassmann","description":"Generate a schema from JSON objects","archived":false,"fork":false,"pushed_at":"2024-05-08T10:31:52.000Z","size":64,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-08T11:35:47.076Z","etag":null,"topics":["cli","generator","json","model","schema"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/schermz","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trassmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-14T11:55:54.000Z","updated_at":"2024-06-18T11:55:03.934Z","dependencies_parsed_at":null,"dependency_job_id":"4cd501e7-f189-4ced-a9bf-a56271fba210","html_url":"https://github.com/trassmann/schermz","commit_stats":null,"previous_names":["trassmann/schermz"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trassmann%2Fschermz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trassmann%2Fschermz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trassmann%2Fschermz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trassmann%2Fschermz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trassmann","download_url":"https://codeload.github.com/trassmann/schermz/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223290318,"owners_count":17120888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","generator","json","model","schema"],"created_at":"2024-08-01T15:05:56.610Z","updated_at":"2024-11-06T05:31:00.802Z","avatar_url":"https://github.com/trassmann.png","language":"Rust","funding_links":[],"categories":["Rust","cli"],"sub_categories":[],"readme":"# schermz\n\nA CLI tool to create a schema from a JSON file.\n\n## Installation\n\nThis tool is written in Rust, so you'll need to install the [Rust toolchain](https://www.rust-lang.org/tools/install) to build it.\n\n```bash\ncargo install schermz\n```\n\n## Usage\n\n```bash\nA tool to generate a schema for a given JSON file.\n\nUsage: schermz [OPTIONS] --file \u003cFILE\u003e\n\nOptions:\n  -f, --file \u003cFILE\u003e    Path to the JSON file\n  -m, --merge-objects  Whether to merge object types into one\n  -h, --help           Print help\n  -V, --version        Print version\n```\n\n## The `-m` argument\n\nWhen this argument is passed to schermz, all objects for the same key will be merged into one, meaning, if a key can have multiple different object shapes, they will not be listed separately. This is useful when you want to get a general idea of the data, or you trust that the data is consistent.\n\nHere's a simple example:\n\n`sample.json`\n\n```json\n[\n  {\n    \"info\": {\n      \"name\": \"Martin\",\n      \"age\": 30\n    }\n  },\n  {\n    \"info\": {\n      \"name\": \"Paul\"\n    }\n  }\n]\n```\n\n### Without `-m` (default)\n\n```bash\nschermz -f ./sample.json\n\n{\n  \"info\": {\n    \"types\": [\n      {\n        \"age\": {\n          \"types\": [\n            \"NUMBER\"\n          ]\n        },\n        \"name\": {\n          \"types\": [\n            \"STRING(6)\"\n          ]\n        }\n      },\n      {\n        \"name\": {\n          \"types\": [\n            \"STRING(4)\"\n          ]\n        }\n      }\n    ]\n  }\n}\n```\n\n### With `-m`\n\n```bash\nschermz -m -f ./sample.json\n\n{\n  \"info\": {\n    \"types\": [\n      {\n        \"age\": {\n          \"types\": [\n            \"NUMBER\"\n          ]\n        },\n        \"name\": {\n          \"types\": [\n            \"STRING(4, 6)\"\n          ]\n        }\n      }\n    ]\n  }\n}\n\n```\n\n## Output\n\nString values are analyzed based on their possible lengths.\n\n- `STRING(0, 10)` - This field is a string with a minimum length of 0 (`\"\"`) and a maximum length of 10.\n- `STRING(5)` - This field is a string with a length of 5.\n\n## Example\n\n`sample.json`\n\n```json\n[\n  {\n    \"name\": \"Sherlock Holmes\",\n    \"title\": \"\",\n    \"age\": 34,\n    \"personal_data\": {\n      \"gender\": \"male\",\n      \"marital_status\": \"single\"\n    },\n    \"address\": {\n      \"street\": \"10 Downing Street\",\n      \"city\": \"London\",\n      \"zip\": \"12345\",\n      \"country_code\": \"UK\"\n    },\n    \"phones\": [\"+44 1234567\", \"+44 2345678\", 12311, { \"mobile\": \"+44 3456789\" }]\n  },\n  {\n    \"name\": \"Tony Soprano\",\n    \"title\": \"\",\n    \"age\": 39,\n    \"personal_data\": {\n      \"gender\": \"male\",\n      \"marital_status\": \"married\"\n    },\n    \"address\": {\n      \"street\": \"14 Aspen Drive\",\n      \"city\": \"Caldwell\",\n      \"zip\": \"NJ 07006\",\n      \"country\": \"USA\",\n      \"state\": \"New Jersey\",\n      \"country_code\": \"US\"\n    },\n    \"phones\": [\n      \"+1 1234567\",\n      \"+1 2345678\",\n      \"+1 11111111111\",\n      \"+1 301234566\",\n      11224234,\n      { \"mobile\": \"+1 3456789\" }\n    ]\n  },\n  {\n    \"name\": \"Angela Merkel\",\n    \"title\": \"\",\n    \"age\": 65,\n    \"personal_data\": {\n      \"gender\": \"female\",\n      \"marital_status\": \"married\"\n    },\n    \"address\": {\n      \"street\": \"Gr. Weg 3\",\n      \"city\": \"Potsdam\",\n      \"zip\": \"14467\",\n      \"country\": \"Germany\",\n      \"state\": \"Brandenburg\"\n    },\n    \"phones\": [\n      \"+49 1234222567\",\n      \"+49 2343231678\",\n      \"+49 1111131111111\",\n      \"+49 301212334566\",\n      9999222,\n      { \"mobile\": \"+49 343156789\", \"fax\": \"+49 343156780\" }\n    ]\n  },\n  {\n    \"name\": \"Jane Doe\",\n    \"title\": \"Dr.\",\n    \"age\": \"73\",\n    \"personal_data\": {\n      \"gender\": \"female\"\n    },\n    \"address\": null,\n    \"phones\": null\n  }\n]\n```\n\n```bash\nschermz -f ./sample.json\n\n{\n  \"address\": {\n    \"types\": [\n      \"NULL\",\n      {\n        \"city\": {\n          \"types\": [\"STRING(6)\"]\n        },\n        \"country_code\": {\n          \"types\": [\"STRING(2)\"]\n        },\n        \"street\": {\n          \"types\": [\"STRING(17)\"]\n        },\n        \"zip\": {\n          \"types\": [\"STRING(5)\"]\n        }\n      },\n      {\n        \"city\": {\n          \"types\": [\"STRING(8)\"]\n        },\n        \"country\": {\n          \"types\": [\"STRING(3)\"]\n        },\n        \"country_code\": {\n          \"types\": [\"STRING(2)\"]\n        },\n        \"state\": {\n          \"types\": [\"STRING(10)\"]\n        },\n        \"street\": {\n          \"types\": [\"STRING(14)\"]\n        },\n        \"zip\": {\n          \"types\": [\"STRING(8)\"]\n        }\n      },\n      {\n        \"city\": {\n          \"types\": [\"STRING(7)\"]\n        },\n        \"country\": {\n          \"types\": [\"STRING(7)\"]\n        },\n        \"state\": {\n          \"types\": [\"STRING(11)\"]\n        },\n        \"street\": {\n          \"types\": [\"STRING(9)\"]\n        },\n        \"zip\": {\n          \"types\": [\"STRING(5)\"]\n        }\n      }\n    ]\n  },\n  \"age\": {\n    \"types\": [\"NUMBER\", \"STRING(2)\"]\n  },\n  \"name\": {\n    \"types\": [\"STRING(8, 15)\"]\n  },\n  \"personal_data\": {\n    \"types\": [\n      {\n        \"gender\": {\n          \"types\": [\"STRING(4, 6)\"]\n        },\n        \"marital_status\": {\n          \"types\": [\"STRING(6, 7)\"]\n        }\n      },\n      {\n        \"gender\": {\n          \"types\": [\"STRING(6)\"]\n        }\n      }\n    ]\n  },\n  \"phones\": {\n    \"types\": [\n      \"NULL\",\n      {\n        \"ARRAY\": [\n          {\n            \"mobile\": {\n              \"types\": [\"STRING(10, 11)\"]\n            }\n          },\n          {\n            \"fax\": {\n              \"types\": [\"STRING(13)\"]\n            },\n            \"mobile\": {\n              \"types\": [\"STRING(13)\"]\n            }\n          },\n          \"NUMBER\",\n          \"STRING(10, 17)\"\n        ]\n      }\n    ]\n  },\n  \"title\": {\n    \"types\": [\"STRING(0, 3)\"]\n  }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrassmann%2Fschermz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrassmann%2Fschermz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrassmann%2Fschermz/lists"}