Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate with annotations #26

Open
kostya opened this issue Jul 16, 2018 · 1 comment
Open

integrate with annotations #26

kostya opened this issue Jul 16, 2018 · 1 comment

Comments

@kostya
Copy link

kostya commented Jul 16, 2018

crystal recently added annotations and json serialization on it (https://github.com/crystal-lang/crystal/blob/master/src/json/serialization.cr):

so if protobuf integrate it can be much nicer to write mappings and also allow some more things like also add json serialization to the class, and other stuffs:

struct MyMessage
  include Protobuf::Serializable
  include JSON::Serializable

  # some required properties
  @[Protobuf::Field(num: 1)]
  property prop_name = 123

  @[Protobuf::Field(num: 2)]
  property prop2 : Foo

  # optional propertie
  @[Protobuf::Field(num: 3)]
  property optional_prop_name : String?

  # repeated fields
  @[Protobuf::Field(num: 4)]
  property my_array : Array(Int32)?
end

btw, this num option also can be generated automatically.

@jeromegn
Copy link
Owner

jeromegn commented Jul 16, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants