Coder Social home page Coder Social logo

Comments (3)

starwing avatar starwing commented on June 2, 2024

to check with official protoc implement, the "optional oneof name" is "_field", so change name to fit it.

from lua-protobuf.

iruno avatar iruno commented on June 2, 2024

I see prefix is changed:

{"eventId":"175d252a-fd72-4e01-8260-88929a9b2aa9","_eventId":"eventId", "eventTime":{"timestampUTC":1413525601,"_timestampUTC":"timestampUTC"},"_eventTime":"eventTime"}

But I want to get the same result I had in 0.3.3. I do not want to have "_"-prefixed extra fields at all.
When I serialize the same object to json in java using com.google.protobuf.util.JsonFormat.Printer, I have no "_"-prefixed fileds generated.

Is it possible to implement it some way?
May be new option like "enable_proto3_optional_fields_generation=false"?


UPD: 'oneof' is not used in my proro file at all.

...

message ZonedTime {

  // Seconds since 1970-01-01 midnight UTC.  For \"2022-03-22 16:47:37 (MSK)\":
  optional int32 timestampUTC = 516260016;

  // Optional.  TZ name
  optional string zone = 3744684;

}

message Event {

  // The identifier of the notification.
  optional string eventId = 302760621;

  optional ZonedTime eventTime = 31415431;
}

from lua-protobuf.

starwing avatar starwing commented on June 2, 2024

Unfortunately it may difficult to do. The optional in proto3 is just a syntax sugar of single field oneof, and there is no way to distinguish it with single field oneof in FileDescriptor. In luapb, all oneof has a field set to indicate which field is setting. I cannot just ignore it for optional field.

from lua-protobuf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.