Created
October 12, 2018 11:32
-
-
Save msroz/0eeca854b743ce4712e5f57e7e6e2ec5 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
syntax = 'proto3'; | |
message User { | |
string first_name = 1; | |
string last_name = 2; | |
} |
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
require_relative './lib/user_pb' | |
require 'ap' | |
-> { | |
user = User.new(first_name: "Taro", last_name: "Yamada") | |
ap user.first_name | |
ap user.last_name | |
user.first_name = "Tanaka" | |
ap user.first_name | |
encoded_data = User.encode(user) | |
File.write("user.proto.encoded", encoded_data) | |
user2 = User.decode(encoded_data) | |
ap user2 | |
ap user2.to_json | |
}.call |
Author
msroz
commented
Oct 12, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment