{"id":22941249,"url":"https://github.com/ahnlabcloudmatelabs/jsonld-helper-ts","last_synced_at":"2025-04-01T20:43:36.511Z","repository":{"id":199583214,"uuid":"700253047","full_name":"ahnlabcloudmatelabs/jsonld-helper-ts","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-12T15:01:19.000Z","size":81,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-12T03:15:27.023Z","etag":null,"topics":["json-ld","jsonld","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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-04T08:40:40.000Z","updated_at":"2023-11-15T07:03:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"48d23562-6ddc-4b27-88c6-5090aac41b29","html_url":"https://github.com/ahnlabcloudmatelabs/jsonld-helper-ts","commit_stats":null,"previous_names":["cloudmatelabs/jsonld-helper-ts","ahnlabcloudmatelabs/jsonld-helper-ts"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahnlabcloudmatelabs%2Fjsonld-helper-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahnlabcloudmatelabs%2Fjsonld-helper-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahnlabcloudmatelabs%2Fjsonld-helper-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahnlabcloudmatelabs%2Fjsonld-helper-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahnlabcloudmatelabs","download_url":"https://codeload.github.com/ahnlabcloudmatelabs/jsonld-helper-ts/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":["json-ld","jsonld","typescript"],"created_at":"2024-12-14T13:38:20.363Z","updated_at":"2025-04-01T20:43:36.490Z","avatar_url":"https://github.com/ahnlabcloudmatelabs.png","language":"TypeScript","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![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge\u0026logo=typescript\u0026logoColor=white)\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\n# npm\nnpm install @cloudmatelabs/jsonld-helper\n\n# yarn\nyarn add @cloudmatelabs/jsonld-helper\n\n# pnpm\npnpm add @cloudmatelabs/jsonld-helper\n\n# bun\nbun add @cloudmatelabs/jsonld-helper\n```\n\n## Usage\n\n```ts\nimport { JsonLDReader } from '@cloudmatelabs/jsonld-helper'\n\nconst jsonld = await JsonLDReader.parse({\n  \"@context\": [\n    \"https://www.w3.org/ns/activitystreams\",\n    {\n      \"manuallyApprovesFollowers\": \"as:manuallyApprovesFollowers\"\n    }\n  ],\n  \"@id\": \"https://mastodon.social/users/juunini\",\n  \"as:type\": \"Person\",\n  \"url\": \"https://mastodon.social/@juunini\",\n  \"as:image\": {\n    \"@type\": \"Image\",\n    \"as:mediaType\": \"image/png\",\n    \"url\": \"https://files.mastodon.social/accounts/headers/109/408/471/076/954/889/original/f4158a0d06a05763.png\"\n  },\n  \"manuallyApprovesFollowers\": \"true\"\n})\n\nconst imageType = jsonld\n  .read('image')\n  .read('mediaType')\n  .stringOrElse('')\n// image/png\n\nconst imageURL = jsonld\n  .read('image')\n  .read('url')\n  .stringOrThrow()\n// https://files.mastodon.social/accounts/headers/109/408/471/076/954/889/original/f4158a0d06a05763.png\n\nconst id = jsonld.read('id').get()\nconst id = jsonld.read('@id').get()\n// https://mastodon.social/users/juunini\n\nconst type = jsonld.read('type').get()\nconst type = jsonld.read('@type').get()\n// Person\n\nconst manuallyApprovesFollowers = jsonld\n  .read('manuallyApprovesFollowers')\n  .booleanOrElse(false)\n// true\n```\n\n## Methods and Properties\n\n```ts\nJsonLDReader.parse (value: object | object[], options?: Options.Expand): Promise\u003cJsonLDReader\u003e\n\n.value [readonly]: unknown\n.length [readonly]: number\n\n.read (key: string): JsonLDReader\n.read (index: number): JsonLDReader\n\n.get (): unknown\n.getOrThrow (error?: Error): unknown\n.getOrElse (defaultValue: unknown): unknown\n\n.stringOrThrow (error?: Error): string\n.stringOrElse (defaultValue: string): string\n\n.numberOrThrow (error?: Error): number\n.numberOrElse (defaultValue: number): number\n\n.booleanOrThrow (error?: Error): boolean\n.booleanOrElse (defaultValue: boolean): boolean\n```\n\n## License\n\n[MIT](./LICENSE)\n\nBut, this library use [jsonld].  \n[jsonld] is licensed under the [BSD-3-Clause License](https://github.com/digitalbazaar/jsonld.js/blob/main/LICENSE)\n\n[jsonld]: https://github.com/digitalbazaar/jsonld.js\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahnlabcloudmatelabs%2Fjsonld-helper-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahnlabcloudmatelabs%2Fjsonld-helper-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahnlabcloudmatelabs%2Fjsonld-helper-ts/lists"}