{"id":17878007,"url":"https://github.com/bgreni/EmberJson","last_synced_at":"2025-03-22T05:31:39.198Z","repository":{"id":257900576,"uuid":"870760104","full_name":"bgreni/EmberJson","owner":"bgreni","description":"A user friendly json library written in pure Mojo","archived":false,"fork":false,"pushed_at":"2025-03-05T04:47:55.000Z","size":1692,"stargazers_count":20,"open_issues_count":5,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T08:31:39.348Z","etag":null,"topics":["json","json-parser"],"latest_commit_sha":null,"homepage":"","language":"Mojo","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/bgreni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":"github:[bgreni]"},"created_at":"2024-10-10T16:04:58.000Z","updated_at":"2025-03-10T15:27:27.000Z","dependencies_parsed_at":"2024-10-28T12:26:20.337Z","dependency_job_id":"000f1c63-82f3-4217-bcfa-91b81878a300","html_url":"https://github.com/bgreni/EmberJson","commit_stats":null,"previous_names":["bgreni/emberjson"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgreni%2FEmberJson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgreni%2FEmberJson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgreni%2FEmberJson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgreni%2FEmberJson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bgreni","download_url":"https://codeload.github.com/bgreni/EmberJson/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244912800,"owners_count":20530764,"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-parser"],"created_at":"2024-10-28T12:00:40.896Z","updated_at":"2025-03-22T05:31:39.193Z","avatar_url":"https://github.com/bgreni.png","language":"Mojo","funding_links":[],"categories":["🗂️ Libraries\u003ca id='libraries'\u003e\u003c/a\u003e"],"sub_categories":["Web"],"readme":"# EmberJson\n\n\u003c!-- ![emberlogo](./image/ember_logo.jpeg) --\u003e\n\u003cimage src='./image/ember_logo.jpeg' width='300'/\u003e\n\n![license_badge](https://badgen.net/badge/License/MIT/blue)\n![ci_badge](https://github.com/bgreni/EmberJson/actions/workflows/CI.yml/badge.svg)\n\nA lightweight JSON parsing library for Mojo.\n\n## Usage\n\n### Parsing JSON\n\nUse the `parse` function to parse a JSON value from a string. It accepts a\n`ParseOptions` struct as a parameter to alter parsing behaviour.\n\n```mojo\n\nfrom emberjson import parse\n\nstruct ParseOptions:\n    # ignore unicode for a small performance boost\n    var ignore_unicode: Bool\n\n...\n\nvar json = parse[ParseOptions(ignore_unicode=True)](r'[\"\\uD83D\\uDD25\"]')\n```\n\nEmberJSON supports decoding escaped unicode characters.\n\n```mojo\nprint(parse(r'[\"\\uD83D\\uDD25\"]')) # prints '[\"🔥\"]'\n```\n\n### Converting to String\n\nUse the `to_string` function to convert a JSON struct to its string representation.\nIt accepts a parameter to control whether to pretty print the value.\nThe JSON struct also conforms to the `Stringable`, `Representable` and `Writable`\ntraits.\n\n```mojo\nfrom emberjson import to_string\n\nvar json = parse('{\"key\": 123}')\n\nprint(to_string(json)) # prints {\"key\":123}\nprint(to_string[pretty=True](json))\n# prints:\n#{\n#   \"key\": 123\n#}\n```\n\n### Working with JSON\n\n`JSON` is the top level type for a document. It can contain either\nan `Object` or `Array`.\n\n`Value` is used to wrap the various possible primitives that an object or\narray can contain, which are `Int`, `Float64`, `String`, `Bool`, `Object`,\n`Array`, and `Null`.\n\n```mojo\nfrom emberjson import *\n\nvar json = parse('{\"key\": 123}')\n\n# check inner type\nprint(json.is_object()) # prints True\n\n# dict style access\nprint(json.object()[\"key\"].int()) # prints 123\n\n# array\nvar array = parse('[123, 4.5, \"string\", True, null]').array()\n\n# array style access\nprint(array[3].bool()) # prints True\n\n# equality checks\nprint(array[4] == Null()) # prints True\n\n# None converts implicitly to Null\nassert_equal(array[4], Value(None))\n\n# Implicit ctors for Value\nvar v: Value = \"some string\"\n\n# Convert Array and Dict back to stdlib types\n# These are consuming actions so the original Array/Object will be moved\nvar arr = Array(123, False)\nvar l = arr.to_list()\n\nvar ob = Object()\nvar d = ob.to_dict()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgreni%2FEmberJson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbgreni%2FEmberJson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgreni%2FEmberJson/lists"}