{"id":13718260,"url":"https://github.com/edjcase/motoko_cbor","last_synced_at":"2026-01-23T21:52:41.363Z","repository":{"id":49739666,"uuid":"517515672","full_name":"edjCase/motoko_cbor","owner":"edjCase","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-11T18:27:37.000Z","size":127,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-11T20:32:39.896Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Motoko","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/edjCase.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":"2022-07-25T04:23:53.000Z","updated_at":"2025-07-11T18:27:41.000Z","dependencies_parsed_at":"2024-11-14T06:41:40.515Z","dependency_job_id":null,"html_url":"https://github.com/edjCase/motoko_cbor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/edjCase/motoko_cbor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edjCase%2Fmotoko_cbor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edjCase%2Fmotoko_cbor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edjCase%2Fmotoko_cbor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edjCase%2Fmotoko_cbor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edjCase","download_url":"https://codeload.github.com/edjCase/motoko_cbor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edjCase%2Fmotoko_cbor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28700538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T17:25:48.045Z","status":"ssl_error","status_checked_at":"2026-01-23T17:25:47.153Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-08-03T00:08:23.357Z","updated_at":"2026-01-23T21:52:41.358Z","avatar_url":"https://github.com/edjCase.png","language":"Motoko","funding_links":[],"categories":["Libraries"],"sub_categories":["Encoding"],"readme":"## Funding\n\nThis library was originally incentivized by [ICDevs](https://ICDevs.org). You\ncan view more about the bounty on the\n[forum](https://forum.dfinity.org/t/icdevs-org-bounty-18-cbor-and-candid-motoko-parser-3-000/11398)\nor [website](https://icdevs.org/bounties/2022/02/22/CBOR-and-Candid-Motoko-Parser.html). The\nbounty was funded by The ICDevs.org commuity and the award paid to\n@Gekctek. If you use this library and gain value from it, please consider\na [donation](https://icdevs.org/donations.html) to ICDevs.\n\n# Overview\n\nThis is a library that is written in Motoko that enables the encoding and decoding of CBOR between bytes and a CBOR variant type\n\n# Package\n\n### MOPS\n\n```\nmops install cbor\n```\n\nTo setup MOPS package manage, follow the instructions from the [MOPS Site](https://j4mwm-bqaaa-aaaam-qajbq-cai.ic0.app/)\n\n# Usage\n\n### Cbor Bytes -\u003e Cbor Object\n\n```\nimport Cbor \"mo:cbor\";\n\nlet bytes: [Nat8] = [0xbf, 0x63, 0x46, 0x75, 0x6e, 0xf5, 0x63, 0x41, 0x6d, 0x74, 0x21, 0xff];\nlet cbor: Cbor.Value = switch(Cbor.fromBytes(bytes.vals())) {\n    case (#err(e)) ...;\n    case (#ok(c)) c;\n};\n```\n\n### Cbor Object -\u003e Cbor Bytes\n\n```\nimport Cbor \"mo:cbor\";\n\nlet bytes: Cbor.Value = #majorType5([\n    (#majorType3(\"Fun\"), #majorType7(#bool(true))),\n    (#majorType3(\"Amt\"), #majorType1(-2))\n]);\nlet bytes: [Nat8] = switch(Cbor.toBytes(bytes)) {\n    case (#err(e)) ...;\n    case (#ok(c)) c;\n};\n\n```\n\n### Custom Type -\u003e Cbor Bytes\n\n_Not Yet Implemented_\nuse `to_candid(...)`. See https://internetcomputer.org/docs/current/developer-docs/build/cdks/motoko-dfinity/language-manual#candid-serialization\n\n### Cbor Bytes -\u003e Custom Type\n\n_Not Yet Implemented_\nuse `from_candid(...)`. See https://internetcomputer.org/docs/current/developer-docs/build/cdks/motoko-dfinity/language-manual#candid-serialization\n\n# API\n\n`fromBytes(bytes: Iter.Iter\u003cNat8\u003e) : Result.Result\u003cTypes.Value, Types.DecodingError\u003e`\n\nDecodes a series of bytes into a CBOR value variant\n\n`toBytes(value: Types.Value) : Result.Result\u003c[Nat8], Types.EncodingError\u003e`\n\nEncodes a CBOR value into a byte array\n\n`toBytesBuffer(buffer: Buffer.Buffer\u003cNat8\u003e, value: Types.Value) : Result.Result\u003cNat, Types.EncodingError\u003e`\n\nEncodes a CBOR value into the supplied byte buffer and returns the number of bytes written\n\n# Testing\n\n```\nmops test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedjcase%2Fmotoko_cbor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedjcase%2Fmotoko_cbor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedjcase%2Fmotoko_cbor/lists"}