{"id":23441892,"url":"https://github.com/genivia/snapsjot","last_synced_at":"2025-04-09T21:27:02.417Z","repository":{"id":57364608,"uuid":"110844465","full_name":"Genivia/snapSJOT","owner":"Genivia","description":"Companion module for SJOT schemas, creates a SJOT schema from JSON data to efficiently validate and type-check JSON data streams","archived":false,"fork":false,"pushed_at":"2021-04-26T02:01:02.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T13:05:00.946Z","etag":null,"topics":["json-schemas","json-validation","lightweight","schema-checker","sjot-schemas","type-check"],"latest_commit_sha":null,"homepage":"http://sjot.org","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Genivia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-15T14:33:06.000Z","updated_at":"2025-03-19T05:44:25.000Z","dependencies_parsed_at":"2022-09-13T21:01:06.637Z","dependency_job_id":null,"html_url":"https://github.com/Genivia/snapSJOT","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Genivia%2FsnapSJOT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Genivia%2FsnapSJOT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Genivia%2FsnapSJOT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Genivia%2FsnapSJOT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Genivia","download_url":"https://codeload.github.com/Genivia/snapSJOT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248113871,"owners_count":21049922,"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":["json-schemas","json-validation","lightweight","schema-checker","sjot-schemas","type-check"],"created_at":"2024-12-23T17:19:13.217Z","updated_at":"2025-04-09T21:27:02.397Z","avatar_url":"https://github.com/Genivia.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![logo][logo-url]][sjot-url]\n\n[![npm version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![license][bsd-3-image]][bsd-3-url]\n\nsnapSJOT \n========\n\nCreates SJOT schemas from JSON data, a companion module for SJOT schemas\n[sjot.org](http://sjot.org) npm package\n[sjot.js](https://www.npmjs.com/package/sjot) GitHub repository\n[Genivia/SJOT](https://github.com/Genivia/SJOT).\n\n[Live demo](https://www.genivia.com/get-sjot.html#demo) SJOT validator, schema\nconverters and snapSJOT creator.\n\nInstallation\n------------\n\n    npm install snapsjot\n\nHow to snapSJOT JSON\n--------------------\n\n`snapSJOT.convert(data)` returns a SJOT schema for the given JSON or JS value.\nUse snapSJOT with node.js as follows:\n\n```js\nvar snapSJOT = require(\"snapsjot\");\nvar data =\n[\n  {\n    \"name\":    \"SJOT\",\n    \"v\":       \"1.3.7\",\n    \"tags\":    [ \"JSON\", \"SJOT\", \"validator\" ],\n    \"package\": { \"id\": 1, \"name\": \"sjot\" }\n  },\n  {\n    \"name\":    \"SNAPSJOT\",\n    \"v\":       1.3,\n    \"tags\":    [ \"JSON\", \"SJOT\", \"converter\" ],\n    \"package\": { \"id\": 2, \"name\": \"snapsjot\", \"opt\": true }\n  }\n];\nvar schema = snapSJOT.convert(data);\nconsole.log(JSON.stringify(schema, null, 2));\n```\n\nThis creates and displays the following SJOT schema:\n\n```js\n{\n  \"@note\": \"SJOT schema created from JSON data by snapSJOT\",\n  \"@root\": [\n    {\n      \"@final\": true,\n      \"name\": \"string\",\n      \"v\": [[ \"string\", \"number\" ]],\n      \"tags\": [ \"string\" ],\n      \"package\": {\n        \"@final\": true,\n        \"id\": \"number\",\n        \"name\": \"string\",\n        \"opt?\": \"boolean\"\n      }\n    }\n  ]\n}\n```\n\nwhere `@root` specifies that the root type of the JSON data is an array of\nobjects, `@final` means that the object is not extensible (remove if\n    extensibility is desired), the `\"string\"` type matches any string, the\n`\"number\"` type matches any number and the `\"boolean\"` type matches `true` or\n`false`.  These types can be further restricted as specified by [SJOT\nschema](http://sjot.org) syntax.  The `[[ \"string\", \"number\" ]]` with\n`\"string\"` and `\"number\"` types is a type choice that matches any string or\nnumber.  An object property name ending in a `?` is optional.\n\nTo validate JSON or type check JS values with SJOT schemas, use the SJOT\nvalidator by installing npm package [sjot](https://www.npmjs.com/package/sjot):\n\n    npm install sjot\n\nand use `SJOT.valid(data, \"@root\", schema)` to validate `data` against a SJOT\n`schema`:\n\n```js\nvar SJOT = require(\"sjot\");\n\nvar schema = ...; // SJOT schema (e.g. generated with snapSJOT)\n\nvar data = ...;   // some data to validate (or type check)\n\nif (SJOT.valid(data, \"@root\", schema))\n  ... // OK: data validated against schema\n```\n\nBecause snapSJOT generates only one root type, you can simply pass the root\ntype to `SJOT.valid()` to type-check the data as follows:\n\n```js\nvar type = schema[\"@root\"]; // just use the SJOT root type\n\nif (SJOT.valid(data, type))\n  ... // OK: data type-checked\n```\n\nHow to contribute?\n------------------\n\nWe love feedback and contributions to this project.  Please read\n[CONTRIBUTING](CONTRIBUTING.md) for details.\n\nChangelog\n---------\n\n- Nov 14, 2017: snapsjot 1.3.17 added snapSJOT snapsjot.js schema creator to convert JSON data to SJOT schemas\n- Nov 15, 2017: snapsjot 1.3.18 fixed index.js\n- Nov 16, 2017: snapsjot 1.4.0  updates\n- Nov 18, 2017: snapsjot 1.4.1  minor updates\n\n[logo-url]: https://www.genivia.com/images/sjot-logo.png\n[sjot-url]: http://sjot.org\n[npm-image]: https://badge.fury.io/js/snapsjot.svg\n[npm-url]: https://www.npmjs.com/package/snapsjot\n[travis-image]: https://travis-ci.com/Genivia/snapSJOT.svg?branch=master\n[travis-url]: https://travis-ci.com/Genivia/snapSJOT\n[bsd-3-image]: https://img.shields.io/badge/license-BSD%203--Clause-blue.svg\n[bsd-3-url]: https://opensource.org/licenses/BSD-3-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenivia%2Fsnapsjot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenivia%2Fsnapsjot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenivia%2Fsnapsjot/lists"}