package piqi

  1. Overview
  2. Docs
Protocol Buffers, JSON and XML serialization system for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

v0.7.8.tar.gz
sha256=22ee106ad3024b651d080c6c906dac1ad9cd22ece9972742081d09711c764a19
md5=e9bd34d56f33c3fe6cfa133341f96bdf

Description

Published: 09 Aug 2022

README

README.md

Piqi is a multi-format data serialization system for OCaml. It provides a uniform interface for serializing OCaml data structures to JSON, XML and Protocol Buffers formats.

A typical Piqi usage scenario involves the following steps:

1. Install piqi-ocaml -- see installation instructions below.

2. Describe data structures using the Piqi data definition language or Protocol Buffers .proto files

The Piqi data definition language can describe many OCaml types, both primitive and user-defined. This includes integers, floats, booleans, strings, binaries, lists, records and polymorphic variants.

.piqi modules can be converted to and from Protocol Buffers .proto files:

piqi to-proto X.piqi
piqi of-proto X.proto

3. Call the Piqi compiler (piqic-ocaml) to generate OCaml type definitions and serialization code

piqic-ocaml X.piqi

4. Use generated serializes/deserializers in a user's program -- the desired serialization format can be specified at runtime. For examples:

% deserialize a data structure from Protocol Buffers
let buf = Piqirun.init_from_string bytes in
let addressbook = Addressbook_piqi.parse_address_book buf in ...

% serialize it as JSON
let json = Addressbook_piqi_ext.gen_address_book addressbook `json in ...

% serialize it as pretty-printed JSON
let json_pretty = Addressbook_piqi_ext.gen_address_book addressbook `json_pretty in ...

% serialize it as XML
let xml = Addressbook_piqi_ext.gen_address_book addressbook `xml in ...

Examples

See examples/addressbook and other projects in the examples directory.

Installation

Installing using OPAM

In order to install Piqi using OPAM, run the following command:

opam install piqi

This command will install the latest stable version of Piqi that includes piqi and piqic-ocaml executables and runtime libraries for OCaml.

To install the latest development version of Piqi, use opam pinning.

opam pin add -n --dev-repo piqilib
opam pin add -n --dev-repo piqi
opam install piqi

Installing from source code

  1. Download and install piqi and piqilib

Follow general build and installation instructions from the INSTALL file.

After that, build and install the piqilib OCaml library by running

  make ocaml
  make ocaml-install
  1. Build and install piqi-ocaml

make
make install

To uninstall:

make uninstall

Documentation

Piqi OCaml documentation is available at http://piqi.org/doc/ocaml/

The master copy is located in this repository: doc/piqi-ocaml.md

Bugs

Please report found problems using GitHub issues.

Mailing list

http://groups.google.com/group/piqi

Contributing

Your contributions are always welcome. Just open a pull request. Check TODO list for ideas.

Some useful commands:

make test

License

Apache License Version 2.0

Dependencies (4)

  1. stdlib-shims
  2. piqilib
  3. dune >= "2.0.0"
  4. ocaml >= "4.02.0"

Dev Dependencies (1)

  1. num with-test

Used by (8)

  1. bap >= "0.9.8" & < "1.0.0"
  2. bap-frames
  3. bap-piqi
  4. binsec < "0.4.0"
  5. caisar < "2.1"
  6. dtc-pb
  7. kinetic-client < "0.0.11"
  8. riak

Conflicts

None

OCaml

Innovation. Community. Security.