CBOR::Free - Fast CBOR for everyone
$cbor = CBOR::Free::encode( $scalar_or_ar_or_hr ); $thing = CBOR::Free::decode( $cbor ) my $tagged = CBOR::Free::tag( 1, '2019-01-02T00:01:02Z' );
This library implements CBOR via XS under a license that permits commercial usage with no “strings attached”.
This distribution is an experimental effort.
Note that this distribution’s interface can still change. If you decide to use CBOR::Free in your project, please always check the changelog before upgrading.
Encodes a data structure or non-reference scalar to CBOR. The encoder recognizes and encodes integers, floats, binary and UTF-8 strings, array and hash references, CBOR::Free::Tagged instances, Types::Serialiser booleans, and undef (encoded as null).
The encoder currently does not handle any other blessed references.
Notes on mapping Perl to CBOR:
An error is thrown on excess recursion or an unrecognized object.
Decodes a data structure from CBOR. Errors are thrown to indicate invalid CBOR. A warning is thrown if $CBOR is longer than is needed for $data.
Notes on mapping CBOR to Perl:
CBOR UTF-8 strings become Perl UTF-8 strings. CBOR binary strings become Perl binary strings. (This may become configurable later.)
Note that invalid UTF-8 in a CBOR UTF-8 string is considered invalid input and will thus prompt a thrown exception.
CBOR booleans become the corresponding Types::Serialiser values. Both CBOR null and undefined become Perl undef.
Tags are IGNORED for now. (This may become configurable later.)
Tags an item for encoding so that its CBOR encoding will preserve the tag number. (Include $obj, not $DATA, in the data structure that encode() receives.)
encode()
CBOR::Free::true(), CBOR::Free::false(), $CBOR::Free::true, and $CBOR::Free::false are defined as convenience aliases for the equivalent Types::Serialiser values.
CBOR::Free::true()
CBOR::Free::false()
$CBOR::Free::true
$CBOR::Free::false
Most errors are represented via instances of subclasses of CBOR::Free::X.
Add canonical encode().
Make it faster. On some platforms (e.g., Linux) it appears to be faster than JSON::XS but not quite as fast as CBOR::XS; on others (e.g., macOS), it’s slower than both.
Gasper Software Consulting (FELIPE)
This code is licensed under the same license as Perl itself.
CBOR::XS is an older, GPL-licensed CBOR module. It implements some behaviors around CBOR tagging that you might find useful.
To install CBOR::Free, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CBOR::Free
CPAN shell
perl -MCPAN -e shell install CBOR::Free
For more information on module installation, please visit the detailed CPAN module installation guide.