{"id":35711888,"url":"https://github.com/assaabloy-ppi/binson-c-light","last_synced_at":"2026-01-06T04:51:52.469Z","repository":{"id":89587743,"uuid":"51136539","full_name":"assaabloy-ppi/binson-c-light","owner":"assaabloy-ppi","description":"A light-weight C implementation of the Binson serialization format. See https://binson.org/.","archived":false,"fork":false,"pushed_at":"2024-08-13T12:41:35.000Z","size":813,"stargazers_count":5,"open_issues_count":0,"forks_count":5,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-08-13T15:36:07.521Z","etag":null,"topics":["binson","c","clang","serialization"],"latest_commit_sha":null,"homepage":"","language":"C","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/assaabloy-ppi.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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-05T09:05:11.000Z","updated_at":"2024-08-13T15:36:11.839Z","dependencies_parsed_at":"2024-01-16T15:15:39.085Z","dependency_job_id":"a2890713-4ed8-4094-8e00-f023c31e2a9a","html_url":"https://github.com/assaabloy-ppi/binson-c-light","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/assaabloy-ppi/binson-c-light","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assaabloy-ppi%2Fbinson-c-light","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assaabloy-ppi%2Fbinson-c-light/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assaabloy-ppi%2Fbinson-c-light/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assaabloy-ppi%2Fbinson-c-light/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/assaabloy-ppi","download_url":"https://codeload.github.com/assaabloy-ppi/binson-c-light/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assaabloy-ppi%2Fbinson-c-light/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28221940,"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","status":"online","status_checked_at":"2026-01-06T02:00:07.049Z","response_time":56,"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":["binson","c","clang","serialization"],"created_at":"2026-01-06T04:51:48.572Z","updated_at":"2026-01-06T04:51:52.460Z","avatar_url":"https://github.com/assaabloy-ppi.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/assaabloy-ppi/binson-c-light.svg?branch=master)](https://travis-ci.org/assaabloy-ppi/binson-c-light) [![codecov](https://codecov.io/gh/assaabloy-ppi/binson-c-light/branch/master/graph/badge.svg)](https://codecov.io/gh/assaabloy-ppi/binson-c-light)\n\n\n# binson-c-light\n\nA light-weight C implementation of the Binson serialization format\n\n\u003e Binson is like JSON, but faster, binary and even simpler. See [binson.org](http://binson.org/)\n\nFeatures\n---------\n\n* Written in c99 standard.\n* Portable MCU-friendly code.\n* Tested at:\n  * x86_64 Linux (gcc, clang)\n  * ARM Cortex-M3\n  * ARM Cortex-M4 (nRF52832 and nRF52840 SoC)\n* Compatible with:\n  * [binson-java](https://github.com/franslundberg/binson-java)\n  * [binson-java-light](https://github.com/franslundberg/binson-java-light)\n* Has no 3rd party dependencies. (libc only)\n* No dynamic memory allocation (in-place parsing)\n\nWriter API usage\n---------\n\n```c\n#include \"binson_light.h\"\n#include \u003cassert.h\u003e\n#include \u003cstdio.h\u003e\n\nint main(void)\n{\n    printf(\"=== Binson writer example ===\\r\\n\");\n    uint8_t        buf[64];\n    size_t         cnt;\n    binson_writer  w;\n\n    binson_writer_init(\u0026w, buf, sizeof(buf));\n\n    // {\"cid\":123}\n    binson_write_object_begin(\u0026w);\n    binson_write_name(\u0026w, \"cid\");\n    binson_write_integer(\u0026w, 123);\n    binson_write_object_end(\u0026w);\n\n    cnt = binson_writer_get_counter(\u0026w);\n\n    printf(\"Hex representation: \");\n    for (size_t i = 0; i \u003c cnt; i++) {\n        printf( \"0x%02x \", buf[i] );\n    }\n    printf(\"\\r\\n\");\n\n    printf(\"JSON Representation: \");\n    BINSON_PARSER_DEF(p);\n    binson_parser_init(\u0026p, buf, cnt);\n    assert(binson_parser_verify(\u0026p));\n    binson_parser_print(\u0026p);\n    printf(\"\\r\\n\");\n\n    return 0;\n}\n```\nWill print:\n\n```\n=== Binson writer example ===\nHex representation: 0x40 0x14 0x03 0x63 0x69 0x64 0x10 0x7b 0x41\nJSON Representation: {\"cid\":123}\n```\n\nParser API usage\n---------\n\n\n```c\n#include \"binson_light.h\"\n#include \u003cassert.h\u003e\n#include \u003cstdio.h\u003e\n\nint main(void)\n{\n    printf(\"=== Binson parser example ===\\r\\n\");\n\n    const uint8_t src[26] = \"\\x40\\x14\\x01\\x61\\x10\\x7b\\x14\\x03\\x62\\x63\\x64\\x14\\x0c\\x48\\x65\\x6c\\x6c\\x6f\\x20\\x77\\x6f\\x72\\x6c\\x64\\x21\\x41\";\n    bbuf          *str;\n    /*\n    * Defines a parser that can parse up to 10 nested objects.\n    * If less or more levels are required use the macro:\n    * BINSON_PARSER_DEF_DEPTH(p, depth).\n    *\n    * It is also possible to do like this:\n    * binson_parser p;\n    * binson_state states[5];\n    * p.state = state;\n    * p.max_depth = 5;\n    *\n    */\n    BINSON_PARSER_DEF(p); /* Default maximum depth = 10 */\n\n    binson_parser_init(\u0026p, src, sizeof(src));\n    assert(binson_parser_verify(\u0026p));\n\n    binson_parser_go_into_object(\u0026p);\n    binson_parser_field(\u0026p, \"a\");\n    printf(\"a: %d\\n\", (int)binson_parser_get_integer(\u0026p));\n\n    binson_parser_field(\u0026p, \"bcd\");\n    str = binson_parser_get_string_bbuf(\u0026p);\n    printf(\"bcd: %*.*s\\n\", 0, (int) str-\u003ebsize, (const char *) str-\u003ebptr);\n    return 0;\n}\n\n```\nWill print:\n\n```\n=== Binson parser example ===\na: 123\nbcd: Hello world!\n```\n\nBinson c++ class example\n---------\n\n```c\n#include \u003cstdio.h\u003e\n#include \"binson.hpp\"\n\nint main(void)\n{\n    // Serialize to binson format\n    uint8_t buf[64];\n    binson_writer w;\n    BINSON_PARSER_DEF(p);\n\n    Binson b;\n    b.put(\"a\", 123);\n    b.put(\"bcd\", \"Hello world!\");\n\n    binson_writer_init(\u0026w, buf, sizeof(buf));\n    b.serialize(\u0026w);\n\n    // Deserialize\n    binson_parser_init(\u0026p, buf, binson_writer_get_counter(\u0026w));\n    Binson b2;\n    b2.deserialize(\u0026p);\n\n    printf(\"a: %d\\n\", (int)b2.get(\"a\").getInt());\n    printf(\"bcd: %s\\n\", b2.get(\"bcd\").getString().c_str());\n}\n\n```\nWill print:\n\n```\n=== Binson class example ===\na: 123\nbcd: Hello world!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassaabloy-ppi%2Fbinson-c-light","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fassaabloy-ppi%2Fbinson-c-light","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassaabloy-ppi%2Fbinson-c-light/lists"}