10427abbcSEd MasteTutorial 20427abbcSEd Maste=========================== 30427abbcSEd Maste 40427abbcSEd Maste*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/>`_. 50427abbcSEd Maste 60427abbcSEd Maste 70427abbcSEd MasteWhere to start 80427abbcSEd Maste-------------- 90427abbcSEd Maste 100427abbcSEd Maste- Skim through the Crash course section below. 110427abbcSEd Maste- 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>`_. 120427abbcSEd Maste- The :doc:`API documentation <api>` is a complete reference of *libcbor*. 130427abbcSEd Maste 140427abbcSEd Maste 150427abbcSEd MasteCrash course 160427abbcSEd Maste---------------- 170427abbcSEd Maste 180427abbcSEd MasteCBOR data objects are ``cbor_item_t`` 190427abbcSEd Maste^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 200427abbcSEd Maste 210427abbcSEd Maste.. literalinclude:: ../../examples/crash_course.c 220427abbcSEd Maste :language: C 230427abbcSEd Maste :start-after: // Part 1: Begin 240427abbcSEd Maste :end-before: // Part 1: End 250427abbcSEd Maste 260427abbcSEd Maste 270427abbcSEd MasteObjects can be serialized and deserialized 280427abbcSEd Maste^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 290427abbcSEd Maste 300427abbcSEd Maste.. literalinclude:: ../../examples/crash_course.c 310427abbcSEd Maste :language: C 320427abbcSEd Maste :start-after: // Part 2: Begin 330427abbcSEd Maste :end-before: // Part 2: End 340427abbcSEd Maste 350427abbcSEd Maste 360427abbcSEd MasteReference counting 370427abbcSEd Maste^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 380427abbcSEd Maste 390427abbcSEd Maste.. literalinclude:: ../../examples/crash_course.c 400427abbcSEd Maste :language: C 410427abbcSEd Maste :start-after: // Part 3: Begin 420427abbcSEd Maste :end-before: // Part 3: End 430427abbcSEd Maste 440427abbcSEd Maste 450427abbcSEd MasteMoving intermediate values 460427abbcSEd Maste^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 470427abbcSEd Maste 480427abbcSEd Maste.. literalinclude:: ../../examples/crash_course.c 490427abbcSEd Maste :language: C 500427abbcSEd Maste :start-after: // Part 4: Begin 510427abbcSEd Maste :end-before: // Part 4: End 520427abbcSEd Maste 530427abbcSEd Maste 540427abbcSEd MasteOwnership 550427abbcSEd Maste^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 560427abbcSEd Maste 570427abbcSEd Maste.. literalinclude:: ../../examples/crash_course.c 580427abbcSEd Maste :language: C 590427abbcSEd Maste :start-after: // Part 5: Begin 600427abbcSEd Maste :end-before: // Part 5: End 610427abbcSEd Maste 620427abbcSEd Maste 630427abbcSEd MasteStreaming IO 640427abbcSEd Maste^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 650427abbcSEd Maste 660427abbcSEd MasteSee https://github.com/PJK/libcbor/blob/master/examples/streaming_array.c, https://github.com/PJK/libcbor/blob/master/examples/streaming_parser.c