{"id":13410488,"url":"https://github.com/onox/json-ada","last_synced_at":"2026-02-19T10:19:02.423Z","repository":{"id":50643413,"uuid":"64567463","full_name":"onox/json-ada","owner":"onox","description":"An Ada 2012 library for parsing JSON","archived":false,"fork":false,"pushed_at":"2024-07-28T16:06:01.000Z","size":280,"stargazers_count":39,"open_issues_count":1,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-07-31T20:42:48.002Z","etag":null,"topics":["ada","json","json-ada"],"latest_commit_sha":null,"homepage":"","language":"Ada","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2016-07-30T22:59:37.000Z","updated_at":"2024-07-28T16:06:04.000Z","dependencies_parsed_at":"2024-10-26T05:51:04.328Z","dependency_job_id":"c9314ab8-534a-4889-b1c0-de5b1abbc211","html_url":"https://github.com/onox/json-ada","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onox%2Fjson-ada","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onox%2Fjson-ada/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onox%2Fjson-ada/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onox%2Fjson-ada/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onox","download_url":"https://codeload.github.com/onox/json-ada/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243610212,"owners_count":20318922,"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":["ada","json","json-ada"],"created_at":"2024-07-30T20:01:07.277Z","updated_at":"2026-02-19T10:18:57.381Z","avatar_url":"https://github.com/onox.png","language":"Ada","funding_links":[],"categories":["Libraries"],"sub_categories":["Format Readers and Writers","Format Readers, Writers and Checkers"],"readme":"[![Build status](https://github.com/onox/json-ada/actions/workflows/build.yaml/badge.svg)](https://github.com/onox/json-ada/actions/workflows/build.yaml)\n[![Test status](https://github.com/onox/json-ada/actions/workflows/test.yml/badge.svg)](https://github.com/onox/json-ada/actions/workflows/test.yml)\n[![Alire json](https://img.shields.io/endpoint?url=https://alire.ada.dev/badges/json.json)](https://alire.ada.dev/crates/json.html)\n[![License](https://img.shields.io/github/license/onox/json-ada.svg?color=blue)](https://github.com/onox/json-ada/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/onox/json-ada.svg)](https://github.com/onox/json-ada/releases/latest)\n[![IRC](https://img.shields.io/badge/IRC-%23ada%20on%20libera.chat-orange.svg)](https://libera.chat)\n[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/ada-lang/Lobby)\n\n# json-ada\n\nAn Ada 2012 library for parsing JSON ([RFC 7159][url-rfc]). It supports\nAda 2012's iterator and indexing syntax. The RFC does not support\ncomments, thus this library does not support it either. If your JSON data\ncontains comments, you should minify the data so that comments are removed.\n\nEscaped Unicode (`\\u`) in strings is not supported yet.\n\n## Usage\n\n```ada\nwith Ada.Command_Line;\nwith Ada.Text_IO;\n\nwith JSON.Parsers;\nwith JSON.Types;\n\nprocedure Example is\n   package Types   is new JSON.Types (Long_Integer, Long_Float);\n   package Parsers is new JSON.Parsers (Types);\n\n   Parser : Parsers.Parser := Parsers.Create_From_File (Ada.Command_Line.Argument (1));\n   Value  : constant Types.JSON_Value := Parser.Parse;\n\n   use Types;\nbegin\n   --  The data type of a Value can be retrieved with `Value.Kind`. The value\n   --  can be one of:\n   --\n   --  Null_Kind, Boolean_Kind, Integer_Kind, Float_Kind, String_Kind,\n   --  Array_Kind, or Object_Kind.\n   case Value.Kind is\n      when Array_Kind | Object_Kind =\u003e\n         --  Query the length of a JSON array or object with the function `Length`\n         Ada.Text_IO.Put_Line (Value.Length'Image);\n\n         --  A JSON object provides the function `Contains`\n         if Value.Kind = Object_Kind and then Value.Contains (\"foo\") then\n            --  To get an element of a JSON array or object write `Value.Get (Index_Or_Key)`\n            --  or use Ada 2012's indexing syntax `Value (Index_Or_Key)`.\n            --\n            --  If Value is a JSON object, you can call `Get_Array_Or_Empty`,\n            --  `Get_Object_Or_Empty`, or `Get` (with an additional parameter containing\n            --  the default value).\n            Ada.Text_IO.Put_Line (Value (\"foo\").Kind'Image);\n         end if;\n\n         --  Iterate over a JSON array or object by using the\n         --  Ada 2012 iterator syntax `for Element_Or_Key of Value`. The type is a\n         --  JSON_Value and represents an element of the array or the key of an object.\n         for Element of Value loop\n            --  To get the image of JSON_Value (to serialize it), use function `Image`:\n            Ada.Text_IO.Put_Line (Element.Image);\n         end loop;\n      when Float_Kind =\u003e\n         declare\n            --  Get the value (String, generic Integer_Type or Float_Type, or Boolean)\n            --  of a Value by calling `Value.Value`. An Invalid_Type_Error\n            --  exception will be raised if Value has a different type than the type\n            --  of the variable in which you try to store the result.\n            Data : constant Long_Float := Value.Value;\n         begin\n            Ada.Text_IO.Put_Line (Data'Image);\n         end;\n      when others =\u003e\n         null;\n   end case;\nend Example;\n```\n\nOptional generic parameters of `JSON.Types`:\n\n- `Maximum_Number_Length` (default is 30): Maximum length in characters of\n  numbers\n\nOptional generic parameters of `JSON.Parsers`:\n\n- `Default_Maximum_Depth` (default is 10)\n\n- `Check_Duplicate_Keys` (default is False): Check for duplicate keys when\n  parsing. Parsing large JSON texts will be slower if enabled. If disabled\n  then the `Get` operation will return the value of the first key that matches.\n\nA parser can be created by calling `Create_From_File` or `Create`.\nThe actual parameter of `Create` can be some text as a `String`\nor an access to a `Ada.Streams.Stream_Element_Array` containing the text.\nIn case an access to a `Stream_Element_Array` is given, then the `Parser`\ntakes no ownership of the pointer and you must deallocate the array yourself.\n\nThe default maximum nesting depth can be overriden with\nthe optional second parameter `Maximum_Depth` of function `Create`.\n\nAfter parsing, elements of arrays and objects are stored in the `Parser`\nobject, while strings remain stored in the `String` or `Stream_Element_Array`.\nTherefore, the `Parser` object must not go out of scope before any `JSON_Value`\ngoes out of scope.\n\n## Dependencies\n\nIn order to build the library, you need to have:\n\n * An Ada 2012 compiler\n\n * [Alire][url-alire]\n\nOptional dependencies:\n\n * `gcovr` to generate a coverage report for unit tests\n\n * `make`\n\n## Using the library\n\nUse the library in your crates as follows:\n\n```\n$ alr with json\n```\n\n## Tools\n\nThe JSON pretty printer can be run as follows:\n\n```\n$ alr run -q --args=path/to/file.json\n```\n\n## Tests\n\nThe project contains a set of unit tests. Use `make tests` to build and\nrun the unit tests. A coverage report can be generated with `make coverage`:\n\n```\n$ make tests\n$ make coverage\n```\n\n## Contributing\n\nRead the [contributing guidelines][url-contributing] if you want to add\na bugfix or an improvement.\n\n## License\n\nThe Ada code and unit tests are licensed under the [Apache License 2.0][url-apache].\nThe first line of each Ada file should contain an SPDX license identifier tag that\nrefers to this license:\n\n    SPDX-License-Identifier: Apache-2.0\n\n  [url-alire]: https://alire.ada.dev/\n  [url-rfc]: https://tools.ietf.org/html/rfc7159\n  [url-apache]: https://opensource.org/licenses/Apache-2.0\n  [url-contributing]: /CONTRIBUTING.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonox%2Fjson-ada","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonox%2Fjson-ada","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonox%2Fjson-ada/lists"}