1Tutorial 2=========================== 3 4*libcbor* is a C library to encode, decode, and manipulate CBOR data. It is to CBOR to what `cJSON <https://github.com/DaveGamble/cJSON>`_ is to JSON. We assume you are familiar with the CBOR standard. If not, we recommend `cbor.io <http://cbor.io/>`_. 5 6 7Where to start 8-------------- 9 10- Skim through the Crash course section below. 11- Examples of of how to read, write, manipulate, and translate data to and from JSON using *libcbor* are in the `examples directory <https://github.com/PJK/libcbor/tree/master/examples>`_. 12- The :doc:`API documentation <api>` is a complete reference of *libcbor*. 13 14 15Crash course 16---------------- 17 18CBOR data objects are ``cbor_item_t`` 19^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 21.. literalinclude:: ../../examples/crash_course.c 22 :language: C 23 :start-after: // Part 1: Begin 24 :end-before: // Part 1: End 25 26 27Objects can be serialized and deserialized 28^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 30.. literalinclude:: ../../examples/crash_course.c 31 :language: C 32 :start-after: // Part 2: Begin 33 :end-before: // Part 2: End 34 35 36Reference counting 37^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 39.. literalinclude:: ../../examples/crash_course.c 40 :language: C 41 :start-after: // Part 3: Begin 42 :end-before: // Part 3: End 43 44 45Moving intermediate values 46^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 48.. literalinclude:: ../../examples/crash_course.c 49 :language: C 50 :start-after: // Part 4: Begin 51 :end-before: // Part 4: End 52 53 54Ownership 55^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 56 57.. literalinclude:: ../../examples/crash_course.c 58 :language: C 59 :start-after: // Part 5: Begin 60 :end-before: // Part 5: End 61 62 63Streaming IO 64^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65 66See https://github.com/PJK/libcbor/blob/master/examples/streaming_array.c, https://github.com/PJK/libcbor/blob/master/examples/streaming_parser.c