{"id":13543999,"url":"https://github.com/rluba/jaison","last_synced_at":"2025-04-02T13:31:26.118Z","repository":{"id":48548434,"uuid":"308071087","full_name":"rluba/jaison","owner":"rluba","description":"JSON serialization / deserialization module for Jai","archived":false,"fork":false,"pushed_at":"2024-01-03T14:16:24.000Z","size":108,"stargazers_count":41,"open_issues_count":1,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-21T17:11:18.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/rluba.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}},"created_at":"2020-10-28T16:06:50.000Z","updated_at":"2024-05-16T08:52:37.000Z","dependencies_parsed_at":"2024-01-16T17:02:33.881Z","dependency_job_id":"bb65a961-32f4-4c8a-9a8b-345943cdb4ce","html_url":"https://github.com/rluba/jaison","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Fjaison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Fjaison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Fjaison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Fjaison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rluba","download_url":"https://codeload.github.com/rluba/jaison/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246823740,"owners_count":20839773,"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":[],"created_at":"2024-08-01T11:00:40.424Z","updated_at":"2025-04-02T13:31:21.107Z","avatar_url":"https://github.com/rluba.png","language":null,"funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# JSON serialization / deserialization module for Jai\n\n*Attention: This version requires Jai beta 0.1.080!*\nUse `v1.0.0` for older betas.\n\nThis module offers two interfaces:\n* one uses a \"generic tree\" built from `JSON_Value`\n* the other is a typed version that serializes / deserializes your custom data structures.\n\nThe generic `JSON_Value` graphs are a pain to consume and even worse to produce by hand.\nBut they allow you to parse any JSON, even if you don’t know the structure (or can’t reproduce it in Jai because it varies).\n\nThe typed interface is what you want for most cases.\n\n## Parsing / Deserialization\n\nParsing is as simple as:\n\n```Jai\n// Typed version:\nsuccess, result := json_parse_string(json_str, Your_Type_To_Parse_Into);\n// … or if you want to get a generic structure back:\nsuccess, result := json_parse_string(json_str);\n```\n\nThere are also a convenience functions for parsing if the JSON data is in a file:\n\n```Jai\nsuccess, result := json_parse_file(json_filename, Your_Type_To_Parse_Into);\n// … or\nsuccess, result := json_parse_file(json_filename);\n```\n\n\nSee [`typed.jai`](./typed.jai) and [`generic.jai`](./generic.jai) for details and additional options.\n\n### Mixed typed and generic data\n\nIf you don’t know the structure of some subfield of your `Your_Type_To_Parse_Into` structure, but still want to get these values from the JSON data,\nyou can declare these fields as the generic type `JSON_Value` or `*JSON_Value` and the generic parse function will take over at that point:\n\n```\nYour_Type_To_Parse_Into :: struct {\n\tname: string;\n\tage: int;\n\tsomething_we_dont_know_much_about: *JSON_Value; // Whatever structure hides in the JSON, it will be parsed into JSON_Value.\n}\n```\n## Printing / Serialization\n\nGenerating a string works the same for both interfaces:\n\n```Jai\njson_str := json_write_string(my_value);\n```\n\nwhere `my_value` is either a `JSON_Value` or any other data structure.\n\nSee [`module.jai`](./module.jai) for details and additional parameters.\n\n## Dependencies\n\nThis module uses [the `unicode_utils` module](https://github.com/rluba/jai-unicode), which is included as a submodule.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frluba%2Fjaison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frluba%2Fjaison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frluba%2Fjaison/lists"}