{"id":15470870,"url":"https://github.com/andersfugmann/ppx_protocol_conv","last_synced_at":"2025-07-12T03:04:53.128Z","repository":{"id":61664927,"uuid":"111735824","full_name":"andersfugmann/ppx_protocol_conv","owner":"andersfugmann","description":"Pluggable serialization and deserialization of ocaml data strucures based on type_conv","archived":false,"fork":false,"pushed_at":"2025-06-22T17:59:55.000Z","size":523,"stargazers_count":44,"open_issues_count":2,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-22T18:47:40.477Z","etag":null,"topics":["json","jsonm","library","msgpack","ocaml","ppx","serializer","xml","yaml"],"latest_commit_sha":null,"homepage":"https://andersfugmann.github.io/ppx_protocol_conv","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andersfugmann.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog","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,"zenodo":null}},"created_at":"2017-11-22T21:50:15.000Z","updated_at":"2025-01-21T12:19:23.000Z","dependencies_parsed_at":"2023-01-30T01:45:39.411Z","dependency_job_id":"d45be098-d1c1-4710-ac27-df2869979e01","html_url":"https://github.com/andersfugmann/ppx_protocol_conv","commit_stats":{"total_commits":297,"total_committers":9,"mean_commits":33.0,"dds":0.09427609427609429,"last_synced_commit":"1370b1ce96e985e5410a3d899524a9e3de70c772"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/andersfugmann/ppx_protocol_conv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersfugmann%2Fppx_protocol_conv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersfugmann%2Fppx_protocol_conv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersfugmann%2Fppx_protocol_conv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersfugmann%2Fppx_protocol_conv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andersfugmann","download_url":"https://codeload.github.com/andersfugmann/ppx_protocol_conv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersfugmann%2Fppx_protocol_conv/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264928817,"owners_count":23684717,"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","jsonm","library","msgpack","ocaml","ppx","serializer","xml","yaml"],"created_at":"2024-10-02T02:07:25.488Z","updated_at":"2025-07-12T03:04:53.082Z","avatar_url":"https://github.com/andersfugmann.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ppx Protocol Conv\nPpx protocol conv (de)serializers using deriving, which allows for\nplugable\n(de)serializers. [Api](https://andersfugmann.github.io/ppx_protocol_conv).\n\nThis page contains an simple overview of functionality provided.\nMore information is available in the [wiki pages](https://github.com/andersfugmann/ppx_protocol_conv/wiki)\n\n[![Main workflow](https://github.com/andersfugmann/ppx_protocol_conv/actions/workflows/workflow.yml/badge.svg)](https://github.com/andersfugmann/ppx_protocol_conv/actions/workflows/workflow.yml)\n\n# Table of contents\n1. [Features](#features)\n1. [Examples](#examples)\n1. [Drivers](#drivers)\n1. [Custom drivers](#custom-drivers)\n1. [Not supported](#not-supported)\n\n## Features\nThe ppx supports the following features:\n * records\n * recursive and non-recursive types\n * variants\n * polymophic variants\n * All primitive types (except nativeint)\n\nThe following drivers exists\n * `Json` which serializes to `Yojson.Safe.t`\n * `Jsonm` which serializes to `Ezjsonm.value`\n * `Msgpack` which serializes to `Msgpck.t`\n * `Yaml` which serializes to `Yaml.t`\n * `Xml_light` which serializes to `Xml.xml list`\n * `Xmlm` which serializes to `Ezxmlm.node`\n\n## Examples\n```ocaml\nopen Protocol_conv_json\ntype a = {\n  x: int;\n  y: string [@key \"Y\"]\n  z: int list [@default [2;3]]\n} [@@deriving protocol ~driver:(module Json)]\n\ntype b = A of int\n       | B of int [@key \"b\"]\n       | C\n[@@deriving protocol ~driver:(module Json)]\n```\n\nwill generate the functions:\n```ocaml\nval a_to_json: a -\u003e Json.t\nval a_of_json_exn: Json.t -\u003e a\nval a_of_json: Json.t -\u003e (a, exn) result\n\nval b_to_json: a -\u003e Json.t\nval b_of_json_exn: Json.t -\u003e a\nval b_of_json: Json.t -\u003e (b, exn) result\n```\n\n```ocaml\na_to_json { x=42; y:\"really\"; z:[6;7] }\n```\nEvaluates to\n```ocaml\n[ \"x\", `Int 42; \"Y\", `String \"really\"; \"z\", `List [ `Int 6; `Int 7 ] ] (* Yojson.Safe.json *)\n```\n\n`to_protocol` deriver will generate serilisation of the\ntype. `of_protocol` deriver generates de-serilisation of the type,\nwhile `protocol` deriver will generate both serilisation and de-serilisation functions.\n\n## Attributes\nRecord label names can be changed using `[@key \u003cstring\u003e]`\n\nVariant and polymorphic variant constructors names can be changed using the `[@name \u003cstring\u003e]`\nattribute.\n\nIf a record field is not present in the input when deserialising, as default value can be\nassigned using `[@default \u003cexpr\u003e]`. If the value to be serialized\nmatches the default value, the field will be omitted (Some drivers\nallow disabling this functonality. Comparrison uses polymorphic compare, so be careful.\n\n## Signatures\nThe ppx also handles signature, but disallows\n`[@key ...]`, `[@default ...]` and `[@name] ....` as these does not impact signatures.\n\n## Drivers\n\nDrivers specify concrete serialization and deserialization.\nUsers of the library can elect to implement their own driver see\n[custom drivers](#custom-drivers), or use predefined drivers:\n\n * `Json` which serializes to `Yojson.Safe.t`\n * `Jsonm` which serializes to `Ezjsonm.value`\n * `Msgpack` which serializes to `Msgpck.t`\n * `Yaml` which serializes to `Yaml.t`\n * `Xml_light` which serializes to `Xml.xml list`\n * `Xmlm` which serializes to `Ezxmlm.node`\n\n## Custom drivers\nIt is easy to provide custom drivers by implementing the signature:\n\n```ocaml\ninclude Protocol_conv.Runtime.Driver with\n  type t = ...\n```\nSee the `drivers` directory for examples on how to implemented new drivers.\nSubmissions of new drivers are more than welcome.\n\n## Not supported\n* Generalised algebraic datatypes\n* Extensible types\n* Extensible polymorphic variants\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersfugmann%2Fppx_protocol_conv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandersfugmann%2Fppx_protocol_conv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersfugmann%2Fppx_protocol_conv/lists"}