{"id":22003809,"url":"https://github.com/xpodev/python-rson","last_synced_at":"2026-02-27T04:34:35.383Z","repository":{"id":263166604,"uuid":"889564814","full_name":"xpodev/python-rson","owner":"xpodev","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-07T19:03:00.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-29T01:28:21.887Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/xpodev.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":"2024-11-16T16:45:30.000Z","updated_at":"2024-12-07T19:02:59.000Z","dependencies_parsed_at":"2024-11-16T17:28:54.851Z","dependency_job_id":"a09ba189-630b-4041-a13a-c898b8f6e3ba","html_url":"https://github.com/xpodev/python-rson","commit_stats":null,"previous_names":["xpodev/python-rson"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/xpodev/python-rson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpodev%2Fpython-rson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpodev%2Fpython-rson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpodev%2Fpython-rson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpodev%2Fpython-rson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xpodev","download_url":"https://codeload.github.com/xpodev/python-rson/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpodev%2Fpython-rson/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29884783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T23:51:21.483Z","status":"online","status_checked_at":"2026-02-27T02:00:06.759Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-30T00:10:56.914Z","updated_at":"2026-02-27T04:34:35.366Z","avatar_url":"https://github.com/xpodev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python RSON\n\n\nRSON is a superset of the JSON format. It extends JSON with the primary goal of allowing\nreferences in the JSON itself.\n\nIn addition to that, RSON also allows:\n- [x] Line comments\n- [x] Block comments\n- [x] Trailing commas\n\n\u003e These are just some niceties are not the primary goal of the RSON format.\n\n\n## Usage\n\nThe RSON format allows references by adding 2 types of tokens:\n1. DEF node - defines a `ref-name` for the value\n2. REF node - references the given `ref-name`\n\nThe `DEF` node can be used on any JSON value. This node defines a name for the value which can then used\nto refer to the same value.\nThe `REF` node can only appear as an *object value* or an *array member*, and is used to refer to a\ndefined name.\n\nHere is an example of how this would work:\n```json\n// team.rson\n\n[\n    {\n        \"members\": [\n            {\n                \"name\": \"Alice\",\n                \"role\": $ROLE_DEVELOPER\n            },\n            {\n                \"name\": \"Bob\",\n                \"role\": $ROLE_MANAGER\n            },\n            {\n                \"name\": \"Charlie\",\n                \"role\": $ROLE_DESIGNER\n            },\n            {\n                \"name\": \"David\",\n                \"role\": $ROLE_DEVELOPER\n            }\n        ],\n        \"roles\": [\n            {\n                \"name\": \"Developer\"\n            }(ROLE_DEVELOPER),\n            {\n                \"name\": \"Designer\"\n            }(ROLE_DESIGNER),\n            {\n                \"name\": \"Manager\"\n            }(ROLE_MANAGER)\n        ]\n    }\n]\n```\n\nWe can load the `teams.rson` file with the following code:\n```py\nfrom rson import load\n\nwith open(\"teams.rson\") as f:\n    team = load(f)[0]\n\n    target_role_name = input(\"Which role to look for? \")\n\n    for role in team[\"roles\"]:\n        if role[\"name\"].lower() == target_role_name.lower():\n            target_role = role\n            break\n    else:\n        print(\"Could not find role \" + target_role_name)\n        exit()\n\n    members_with_role = [\n        member for member in team[\"members\"]\n        if member[\"role\"] is target_role # \u003c- note the identity check here\n    ]\n\n    print(f\"Found {len(members_with_role)} members with role {role['name']}:\")\n    for i, member in enumerate(members_with_role):\n        print(f\"\\t{i}. {member['name']}\")\n\n```\n\nand a sample execution:\n```\nWhich role to look for? developer\nFound 2 members with role Developer:\n        0. Alice\n        1. David\n```\n\n## Specification\n\nThe `ref-name` must conform to the following regex:\n```re\n[A-Za-z_][A-Za-z_0-9]*\n```\n\nOr, in plain english:\n\u003e The first character must be a valid english letter or an underscore, and the\n\u003e following letters must be either an english letter, an underscore or a digit.\n\u003e A `ref-name` must have at least 1 character (the first character).\n\n\nA `DEF` node can be used for every JSON value, so this makes the following\nvalid as well:\n```json\n{\n    \"organization\": {\n        \"name\": \"Xpo Development\"(ORG_NAME)\n    },\n    \"title\": $ORG_NAME\n}\n```\n\n\n## Contributing\n\nFeel free to open an issue or a PR.\n\n## ToDo\n\n- [x] Implement the `load` function\n- [x] Implement the `loads` function\n- [ ] Implement the `dump` function\n- [ ] Implement the `dumps` function\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpodev%2Fpython-rson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxpodev%2Fpython-rson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpodev%2Fpython-rson/lists"}