{"id":22941251,"url":"https://github.com/ahnlabcloudmatelabs/go-jsonld-helper","last_synced_at":"2025-04-01T20:43:36.846Z","repository":{"id":203259910,"uuid":"709185462","full_name":"ahnlabcloudmatelabs/go-jsonld-helper","owner":"ahnlabcloudmatelabs","description":"when receive any shape of JSON-LD, we can parse and use same interface","archived":false,"fork":false,"pushed_at":"2023-10-25T10:41:12.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-07T13:30:19.691Z","etag":null,"topics":["go","golang","json-ld","jsonld"],"latest_commit_sha":null,"homepage":"","language":"Go","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/ahnlabcloudmatelabs.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":"2023-10-24T07:43:45.000Z","updated_at":"2023-10-26T07:57:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"b40edb3e-3891-45cb-b1da-bacd484da78b","html_url":"https://github.com/ahnlabcloudmatelabs/go-jsonld-helper","commit_stats":null,"previous_names":["cloudmatelabs/go-jsonld-helper","ahnlabcloudmatelabs/go-jsonld-helper"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahnlabcloudmatelabs%2Fgo-jsonld-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahnlabcloudmatelabs%2Fgo-jsonld-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahnlabcloudmatelabs%2Fgo-jsonld-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahnlabcloudmatelabs%2Fgo-jsonld-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahnlabcloudmatelabs","download_url":"https://codeload.github.com/ahnlabcloudmatelabs/go-jsonld-helper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246709919,"owners_count":20821298,"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":["go","golang","json-ld","jsonld"],"created_at":"2024-12-14T13:38:20.511Z","updated_at":"2025-04-01T20:43:36.823Z","avatar_url":"https://github.com/ahnlabcloudmatelabs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n![cloudmate logo](https://avatars.githubusercontent.com/u/69299682?s=200\u0026v=4)\n\n# JSON-LD Helper\n\n\u003csmall style=\"opacity: 0.7;\"\u003eby Cloudmate\u003c/small\u003e\n\n---\n\n![Golang](https://img.shields.io/badge/Go-00ADD8?style=for-the-badge\u0026logo=go\u0026logoColor=white)\n\n[![Go Test](https://github.com/cloudmatelabs/go-jsonld-helper/actions/workflows/gotest.yml/badge.svg)](https://github.com/cloudmatelabs/go-jsonld-helper/actions/workflows/gotest.yml)\n\n\u003c/div\u003e\n\n## Why use this library?\n\nWhen receive JSON-LD,\n\n```json\n{\n  \"@context\": \"https://www.w3.org/ns/activitystreams\",\n  \"name\": \"juunini\",\n  \"type\": \"Person\",\n  \"id\": \"juunini\"\n}\n```\n\nis equals\n\n```json\n{\n  \"@context\": \"https://www.w3.org/ns/activitystreams\",\n  \"as:name\": \"juunini\",\n  \"type\": \"Person\",\n  \"@id\": \"juunini\"\n}\n```\n\nand it also equals\n\n```json\n[\n  {\n    \"https://www.w3.org/ns/activitystreams#name\": [\n      {\n        \"@value\": \"juunini\"\n      }\n    ],\n    \"@id\": \"juunini\",\n    \"https://www.w3.org/ns/activitystreams#type\": [\n      {\n        \"@value\": \"Person\"\n      }\n    ]\n  }\n]\n```\n\nwhen receive any shape of JSON-LD, we can parse and use same interface.\n\n## Installation\n\n```sh\ngo get github.com/cloudmatelabs/go-jsonld-helper\n```\n\n## Usage\n\n```go\nimport (\n  jsonld_helper \"github.com/cloudmatelabs/go-jsonld-helper\"\n)\n\nvar doc = map[string]any{\n\t\"@context\": []any{\n\t\t\"https://www.w3.org/ns/activitystreams\",\n\t\tmap[string]any{\n\t\t\t\"manuallyApprovesFollowers\": \"as:manuallyApprovesFollowers\",\n\t\t},\n\t},\n\t\"@id\":     \"https://mastodon.social/users/juunini\",\n\t\"as:type\": \"Person\",\n\t\"url\":     \"https://mastodon.social/@juunini\",\n\t\"as:image\": map[string]any{\n\t\t\"@type\":        \"Image\",\n\t\t\"as:mediaType\": \"image/png\",\n\t\t\"url\":          \"https://files.mastodon.social/accounts/headers/109/408/471/076/954/889/original/f4158a0d06a05763.png\",\n\t},\n\t\"manuallyApprovesFollowers\": \"true\",\n}\n\njsonld, err := jsonld_helper.ParseJsonLD(doc, nil)\nif err != nil {\n  // handle error\n}\n\nimageType := jsonld.ReadKey(\"image\").ReadKey(\"mediaType\").StringOrElse(\"\")\n// image/png\nimageURL := jsonld.ReadKey(\"image\").ReadKey(\"url\").StringOrThrow()\n// https://files.mastodon.social/accounts/headers/109/408/471/076/954/889/original/f4158a0d06a05763.png\nid := jsonld.ReadKey(\"id\").Get()\nid := jsonld.ReadKey(\"@id\").Get()\n// https://mastodon.social/users/juunini\nmessageType := jsonld.ReadKey(\"type\").Get()\nmessageType := jsonld.ReadKey(\"@type\").Get()\n// Person\nmanuallyApprovesFollowers := jsonld.ReadKey(\"manuallyApprovesFollowers\").BooleanOrElse(false)\n// true\n```\n\n## Methods and Properties\n\n```ts\nimport \"github.com/piprate/json-gold/ld\"\n\njsonld_helper.ParseJsonLD (doc any, options *ld.JsonLdOptions) (JsonLDReader, error)\n\n.Value() any\n.Length() int\n\n.ReadKey(string) JsonLDReader\n.ReadIndex(int) JsonLDReader\n\n.Get() any\n.GetOrElse(any) any\n.GetOrThrow(error) (any, error)\n\n.StringOrElse(string) string\n.StringOrThrow(error) (string, error)\n\n.BoolOrElse(bool) bool\n.BoolOrThrow(error) (bool, error)\n\n.IntOrElse(int) int\n.IntOrThrow(error) (int, error)\n\n.FloatOrElse(float64) float64\n.FloatOrThrow(error) (float64, error)\n```\n\n## License\n\n[MIT](LICENSE)\n\nBut, this library use [json-gold].  \n[json-gold] is licensed under the [Apache License 2.0](https://github.com/kazarena/json-gold/blob/master/LICENSE)\n\n[json-gold]: https://github.com/kazarena/json-gold\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahnlabcloudmatelabs%2Fgo-jsonld-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahnlabcloudmatelabs%2Fgo-jsonld-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahnlabcloudmatelabs%2Fgo-jsonld-helper/lists"}