Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serialization formats that support tagged unions

This question has been asked back in 2012 , but I'm looking for new updates.

Are there any serialization formats that support tagged unions (aka sum types)? My requirements are that it has Java and .Net client libs, and it should be "reasonable mature". Performance is not a major concern.

Avro provides partial support, but does not allow nested unions (http://avro.apache.org/docs/1.7.6/spec.html#Unions). Cap'n Proto appears to have better support, but I'm not sure if it is production ready yet. Transit doesn't have direct support, but does provide an extension mechanism that might be able to support tagged unions.

Any other suggestions, or comments on the above choices?

like image 559
Akash Avatar asked Jan 05 '15 12:01

Akash


1 Answers

Protocol Buffers version 2.6.0 added support for tagged unions in the form of the oneof declaration, but it looks like protobuf-net has not been updated recently so I'm guessing it doesn't support this yet.

Cap'n Proto is used in production in a lot of places (e.g. CloudFlare), but it's true that the C# and Java implementations are relatively new.

(Disclosure: I'm the author of Cap'n Proto, and also of most of Google's open source Protobuf code.)

like image 131
Kenton Varda Avatar answered Sep 27 '22 20:09

Kenton Varda