--- CBOR-XS/XS.pm 2013/10/29 15:13:50 1.12 +++ CBOR-XS/XS.pm 2013/10/29 22:04:52 1.16 @@ -48,6 +48,14 @@ often compresses better than CBOR though, so if you plan to compress the data later you might want to compare both formats first). +To give you a general idea about speed, with texts in the megabyte range, +C usually encodes roughly twice as fast as L or +L and decodes about 15%-30% faster than those. The shorter the +data, the worse L performs in comparison. + +As for compactness, C encoded data structures are usually about +20% smaller than the same data encoded as (compact) JSON or L. + The primary goal of this module is to be I and the secondary goal is to be I. To reach the latter goal it was written in C. @@ -60,7 +68,7 @@ use common::sense; -our $VERSION = 0.05; +our $VERSION = 0.07; our @ISA = qw(Exporter); our @EXPORT = qw(encode_cbor decode_cbor); @@ -285,8 +293,9 @@ =item CBOR::XS::Tagged objects Objects of this type must be arrays consisting of a single C<[tag, value]> -pair. The (numerical) tag will be encoded as a CBOR tag, the value will be -encoded as appropriate for the value. +pair. The (numerical) tag will be encoded as a CBOR tag, the value will +be encoded as appropriate for the value. You cna use C to +create such objects. =item Types::Serialiser::true, Types::Serialiser::false, Types::Serialiser::error @@ -518,6 +527,33 @@ $_[0][1] } +=head2 EXAMPLES + +Here are some examples of C uses to tag objects. + +You can look up CBOR tag value and emanings in the IANA registry at +L. + +Prepend a magic header (C<$CBOR::XS::MAGIC>): + + my $cbor = encode_cbor CBOR::XS::tag 55799, $value; + # same as: + my $cbor = $CBOR::XS::MAGIC . encode_cbor $value; + +Serialise some URIs and a regex in an array: + + my $cbor = encode_cbor [ + (CBOR::XS::tag 32, "http://www.nethype.de/"), + (CBOR::XS::tag 32, "http://software.schmorp.de/"), + (CBOR::XS::tag 35, "^[Pp][Ee][Rr][lL]\$"), + ]; + +Wrap CBOR data in CBOR: + + my $cbor_cbor = encode_cbor + CBOR::XS::tag 24, + encode_cbor [1, 2, 3]; + =head1 CBOR and JSON CBOR is supposed to implement a superset of the JSON data model, and is,