use strict;
use warnings;
use Benchmark qw(cmpthese);
use Sereal;
use JSON::XS ();
use JSON ();
use Google::ProtocolBuffers::Dynamic;
use Getopt::Long;
{
my $d = Google::ProtocolBuffers::Dynamic
my $sereal_encoder = Sereal::Encoder->new;
my $sereal_decoder = Sereal::Decoder->new;
my $json_decoder = JSON::XS->new;
exit main();
sub main {
my %suites = (
decode_maps => \&p
nchmarks = (
bbpb => 'protobuf_bbpb',
upb => 'protobuf_upb',
json => 'json',
sereal => 'sereal',
);
my $error;
my $arg_ok = GetOptions(
r binary data into a message instance.
=head2 decode_json
$msg = Message::Class->decode_json($json_data);
Deserializes Protocol Buffer JSON data into a message instance.
=head2 encode
$se
code_json
$serialized_data = Message::Class->encode_json({ ... });
$serialized_data = Message::Class->encode_json($message_instance);
$serialized_data = $message_instance->encode_json;
S
izes the given message instance (or mix of message instances and
plain hashes) to Protocol Buffer JSON format.
=head2 check
Message::Class->check({ ... });
Message::Class->check($message_ins
Def;
struct MappingOptions {
enum BoolStyle {
Perl = 1,
Numeric = 2,
JSON = 3,
};
enum AccessorStyle {
GetAndSet = 1,
PlainAndSet = 2,
Sin
ude "ref.h"
#include <upb/pb/encoder.h>
#include <upb/pb/decoder.h>
#include <upb/json/printer.h>
#include <upb/json/parser.h>
#include "unordered_map.h"
#include "EXTERN.h"
#include "perl.h"
#incl
l on_numeric_bool(DecoderHandlers *cxt, const int *field_index, bool val);
static bool on_json_bool(DecoderHandlers *cxt, const int *field_index, bool val);
void push_mapper(const Map
bufsize);
SV *decode_bbpb(const char *buffer, STRLEN bufsize);
SV *encode_json(SV *ref);
SV *decode_json(const char *buffer, STRLEN bufsize);
bool check(SV *ref);
const char *las
;
$person = Humans::Person->decode_json('{"id":31,"name":"John Doe"}');
$bytes = Humans::Person->encode($person);
$bytes = Humans::Person->encode_json($person);
# field accessors
C<"">.
=item numeric
Maps C<true> to C<1> and C<false> to C<0>.
=item json
Loads L<JSON> and uses C<JSON::true> and C<JSON::false> as
C<true>/C<false> values.
=back
=head2 check_required_fields
use strict;
use warnings;
use Benchmark qw(cmpthese);
use Sereal;
use JSON::XS ();
use JSON ();
use Google::ProtocolBuffers;
use Google::ProtocolBuffers::Dynamic;
Google::ProtocolBuffers->parsefile(
icPerson->encode($person);
my $sereal_person = $sereal_encoder->encode($person);
my $json_person = JSON::encode_json($person);
sub encode_protobuf_pp_one { Test::Person->encode($person); }
sub encode
de($person); }
sub encode_sereal_one { $sereal_encoder->encode($person); }
sub encode_json_one { JSON::encode_json($person); }
sub decode_protobuf_pp_one { Test::Person->decode($pbd_person); }
sub de