- Java Protobuf Serialization Error
- Java Protobuf Serialize To String
- Java Protobuf Serialization File
- Protobuf Java Tutorial
- Java Protobuf Serialize To String
In Java, the package name is used as the Java package unless you have explicitly specified a javapackage, as we have here. Even if you do provide a javapackage, you should still define a normal package as well to avoid name collisions in the Protocol Buffers name space as well as in non-Java languages.
What needs to be done in order to serialize enums with protobuf-net? I'm getting the below error when serializing a class having an enum property, if the DataMember attribute is removed from the property declaration it works fine.
'System.InvalidOperationException: Onlytrue'>77 gold badges43 silver badges74 bronze badges
2 Answers
I suspect they are actually 2 different scenarios, but with regard to the code sample added by Andrew, this is because it can't figure out (in advance) what it is going to do with regards to default values (by default, data is treated as optional at the receiver). There are 3 ways of fixing this:
1: add an enum with value 0 (since 0 is always the CLI default value for zeros), for example
2: tell it which value to use by default:
3: tell the engine that it really doesn't need to worry about it, i.e. that it is going to have a value:
Marc GravellJava Protobuf Serialization Error
♦Marc GravellNot the answer you're looking for? Browse other questions tagged enumsprotocol-buffersprotobuf-net or ask your own question.
A java serialization library with built-in support for forward-backward compatibility (schema evolution) and validation.
- efficient, both in speed and memory
- flexible, supporting pluggable formats
Java Protobuf Serialize To String
Usecase
Java Protobuf Serialization File
- messaging layer in RPC
- storage format in the datastore or cache
For more information, go to https://protostuff.github.io/docs/
Usage
Maven
- When you generate schemas for your classes
- Runtime schemas
Questions/Concerns/Suggestions
- subscribe to http://groups.google.com/group/protostuff/
Requirements
Java 1.6 or higher
Build Requirements
Protobuf Java Tutorial
Maven 3.2.3 or higher