{"id":18831725,"url":"https://github.com/zweidenker/jsonschema","last_synced_at":"2025-04-14T04:16:46.642Z","repository":{"id":75666176,"uuid":"148150007","full_name":"zweidenker/JSONSchema","owner":"zweidenker","description":"Implementation of JSON schema for pharo","archived":false,"fork":false,"pushed_at":"2024-05-06T13:32:54.000Z","size":827,"stargazers_count":16,"open_issues_count":8,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-14T04:16:41.088Z","etag":null,"topics":["json","json-schema","pharo","smalltalk"],"latest_commit_sha":null,"homepage":null,"language":"Smalltalk","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zweidenker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-09-10T12:14:04.000Z","updated_at":"2024-05-06T13:33:01.000Z","dependencies_parsed_at":"2023-06-07T07:30:20.225Z","dependency_job_id":null,"html_url":"https://github.com/zweidenker/JSONSchema","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweidenker%2FJSONSchema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweidenker%2FJSONSchema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweidenker%2FJSONSchema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweidenker%2FJSONSchema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zweidenker","download_url":"https://codeload.github.com/zweidenker/JSONSchema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819412,"owners_count":21166477,"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","json-schema","pharo","smalltalk"],"created_at":"2024-11-08T01:55:49.820Z","updated_at":"2025-04-14T04:16:46.623Z","avatar_url":"https://github.com/zweidenker.png","language":"Smalltalk","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSONSchema\n\n[![Build Status](https://travis-ci.org/zweidenker/JSONSchema.svg?branch=master)](https://travis-ci.org/zweidenker/JSONSchema)\n[![Test Status](https://api.bob-bench.org/v1/badgeByUrl?branch=master\u0026hosting=github\u0026ci=travis-ci\u0026repo=zweidenker%2FJSONSchema\u0026subNumber=1)](https://bob-bench.org/r/gh/zweidenker/JSONSchema)\n\nThis is an implementation of [JSON Schema](https://json-schema.org/) for the [pharo](http://pharo.org) language. It is used to define the structure and values of a JSON string and to validate it. The schema itself can be externalized for being consumed by a third party.\n\n**DISCLAIMER**: This is not a full implementation of the json schema spec. Basic types and constraints should work. If you need support for something not implemented you are invited to provide a pull request for it. If you cannot develop it you still can open a ticket in this repository\n\nIt can be loaded by downloading it in pharo via\n\n```\n  Metacello new\n    repository: 'github://zweidenker/JSONSchema';\n    baseline: #JSONSchema;\n    load\n```\n## Defining a schema\n\nThese are the expression to create a schema model inside pharo.\n\n```\nschema := {\n  #name -\u003e JSONSchema string.\n  #dateAndTime -\u003e (JSONSchema stringWithFormat: 'date-time').\n  #numberOfPets -\u003e JSONSchema number } asJSONSchema.\n\n```\n\ndefines as schema that can parse the following JSON:\n\n```\njsonString := '{\n  \"name\" : \"John Doe\",\n  \"dateAndTime\" : \"1970-01-01T14:00:00\",\n  \"numberOfPets\" : 3\n}'.\n```\n\n## Reading/Writing a value using a schema\n\nTo parse the value from JSON we only need to invoke:\n\n```\nvalue := schema readString: jsonString\n```\n\nThe object in ```value``` will have name as a string, dateAndTime as a DateAndTime object and numberOfPets as a SmallInteger object.\n\nThe schema can also be used to write out the value as JSON. This is especially useful if we want to ensure that only valid JSON is written. For this invoke\n\n```\njsonString := schema write: value.\n```\n\n## Serialize/Materialize a schema\n\nAddtionally to reading and writing objects a schema can be serialized to string.\n\n```\nschemaString := NeoJSONWriter toStringPretty: schema.\n```\n\ngives\n\n```\n{\n\t\"type\" : \"object\",\n\t\"properties\" : {\n\t\t\"name\" : {\n\t\t\t\"type\" : \"string\"\n\t\t},\n\t\t\"numberOfPets\" : {\n\t\t\t\"type\" : \"number\"\n\t\t},\n\t\t\"dateAndTime\" : {\n\t\t\t\"type\" : \"string\",\n\t\t\t\"format\" : \"date-time\"\n\t\t}\n\t}\n}\n```\n\n\nIf we would get a schema as string we can instantiate by invoking\n\n```\nschema := JSONSchema fromString: schemaString.\n```\n\n## Nested schemas\n\nSchemas can be nested in any depth. And it can be specified by using the literal Array syntax.\n\n```\nschema := {\n  #name -\u003e JSONSchema string.\n  #address -\u003e {\n    #street -\u003e JSONSchema string.\n    #number -\u003e JSONSchema number\n  } } asJSONSchema\n```\n\n## Constraints\n\nJSON Schema has a defined set of constraints that can be specified. E.g. for a number the inerval of the value can be specified by\n\n```\nnumberSchema := JSONSchema number.\nnumberSchema interval\n  minimum: 1;\n  exclusiveMaximum: 100\n```\nconstraining the number value to be greater or equal to 1 and smaller than 100.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweidenker%2Fjsonschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzweidenker%2Fjsonschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweidenker%2Fjsonschema/lists"}