-
-
Save vividsnow/2141f9a099b978e4710c3d01a823c4db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; use warnings; | |
use Google::ProtocolBuffers::Dynamic; | |
use FindBin qw($Bin); use File::Find; use File::Spec; | |
my $pb = Google::ProtocolBuffers::Dynamic->new(my $path = "$Bin/proto"); | |
find({ wanted => sub { $pb->load_file(File::Spec->abs2rel($_, $path)) if /\.proto$/ }, no_chdir => 1 }, $path); | |
$pb->map({qw'pb_prefix Diadoc.Api.Proto prefix Diadoc'}); | |
# test | |
my $test = '{"OrgId": "test", "Inn": "123", "FullName":"Test", "Sociability":"AllOrganizations", "Address":{ "AddressCode":"RU" }}'; | |
my $org = Diadoc::Organization->decode_json($test); | |
my $bytes = $org->encode; | |
my $org2 = Diadoc::Organization->decode($bytes); | |
print $org2->encode_json, "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment