简体   繁体   中英

why is protobuf-net deserialized DataType object not displayed with Enum value?

We are using the protobuf-net library in order to decode MQTT messages provided from the Inductive Automation - Ignition software, which is based on sparkplug_b.proto payload.

We have generated c# code with the great online protogen tool (with 'should use Enum' checked). So now we are able to decode the binaries message objects, to human readable JSON for example (see below). But the 'Datatype' is not displayed with the enum value by JSON.net. In the Payload there are available enums, Do we have to do manual changes to the auto generated code in order to fix, this?

{
  "Timestamp": 1538568112852,
  "Metrics": [
    {
      "Name": "bdSeq",
      "Timestamp": 1538568112852,
      "Datatype": 4,
      "IsNull": false,
      "LongValue": 0
    }
  ],
  "Seq": 18446744073709551615
}

Sincerely,

I assume you're talking about

public ValueOneofCase ValueCase => (ValueOneofCase)__pbn__value.Discriminator;

I guess maybe your JSON serializer might be skipping it because there isn't a "set" ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM