{"id":16746696,"url":"https://github.com/mkon/ja2r","last_synced_at":"2025-04-10T13:43:36.147Z","repository":{"id":32698113,"uuid":"140315125","full_name":"mkon/ja2r","owner":"mkon","description":"JSON-API to ruby object conversion","archived":false,"fork":false,"pushed_at":"2025-03-11T11:45:53.000Z","size":83,"stargazers_count":1,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T12:21:51.628Z","etag":null,"topics":["json","json-api","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/mkon.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-07-09T16:44:00.000Z","updated_at":"2025-02-19T14:32:34.000Z","dependencies_parsed_at":"2024-04-17T17:49:09.531Z","dependency_job_id":"1f690b4e-c7eb-42a2-9211-70a6423cab74","html_url":"https://github.com/mkon/ja2r","commit_stats":{"total_commits":63,"total_committers":6,"mean_commits":10.5,"dds":0.6984126984126984,"last_synced_commit":"82bf3f48686844a7792b39e6b3b45c6d6b746da9"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkon%2Fja2r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkon%2Fja2r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkon%2Fja2r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkon%2Fja2r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkon","download_url":"https://codeload.github.com/mkon/ja2r/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248226361,"owners_count":21068188,"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-api","ruby"],"created_at":"2024-10-13T02:08:09.307Z","updated_at":"2025-04-10T13:43:36.128Z","avatar_url":"https://github.com/mkon.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JA2R\n\n[![Gem Version](https://badge.fury.io/rb/ja2r.svg)](https://badge.fury.io/rb/ja2r)\n![](https://github.com/mkon/ja2r/workflows/Test/badge.svg?branch=main)\n[![Depfu](https://badges.depfu.com/badges/c63f1c5b6394bba4eb73d3b1063cc0be/overview.svg)](https://depfu.com/github/mkon/ja2r?project_id=5963)\n\nJASON-API to Ruby Object\n\nConverts a JSON-API payload into a ruby object which supports navigation over relationships.\n\n## Usage\n\n```ruby\njson = \u003c\u003c-JSON\n{\n   \"data\":{\n      \"id\":\"1001\",\n      \"type\":\"persons\",\n      \"attributes\":{\n         \"name\":\"Bart\"\n      },\n      \"relationships\":{\n         \"sister\":{\n            \"data\":{\n               \"id\":\"1002\",\n               \"type\":\"persons\"\n            }\n         }\n      }\n   },\n   \"included\":[\n      {\n         \"id\":\"1002\",\n         \"type\":\"persons\",\n         \"attributes\":{\n            \"name\":\"Lisa\"\n         }\n      }\n   ]\n}\nJSON\nbart = JA2R.parse(JSON.parse(json))\nbart.sister.name # Lisa\n```\n\n## Options\n\nYou can pass options to `JA2R#parse` as second argument. Currently the only supported options are:\n\n| Name          | Type    | Description                                                                                                            |\n|---------------|---------|------------------------------------------------------------------------------------------------------------------------|\n| safe_traverse | boolean | When setting this option to true, unknown relationships or attributes will return nil instead of raising NoMethodError |\n\nExample:\n\n```ruby\nbart = JA2R.parse(hash, safe_traverse: true)\nbart.uncle\u0026.name # nil\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkon%2Fja2r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkon%2Fja2r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkon%2Fja2r/lists"}