Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strategy for cross-language (java and c#) object serialization

I'm working on a project where I'll need to serialize some data in a java 6 app and deserialize it a c# 2.0 app. Is there a strategy or something already in existence I can look at that would allow me to do this with these two languages? I'm guessing they both support XML serialization but I really need it to be binary serialized.

like image 446
Lee Warner Avatar asked Jan 04 '10 18:01

Lee Warner


2 Answers

Protocol buffers would be a good option here. On the C# side, I would recommend Jon Skeet's dotnet-protobufs for this use-case, since it has the same API on both sides (his C# version is a port of the Google Java version, part of the core distribution). If you want the C# to be more "typical .NET", then protobuf-net may help.

(the wire format is obviously identical between versions; the API may vary)

Small, fast, efficient, portable.

For info, I know that protobuf-net has .NET 2.0 support; I honestly haven't tried this on Jon's version, but I expect it would - there isn't much that you need 3.0/3.5 for in protobuf.

like image 75
Marc Gravell Avatar answered Oct 05 '22 08:10

Marc Gravell


Protocol Buffers (Google Site)

Java Tutorial

Jon Skeet's C# Port

Marc Gravell's C# Port

Upsides: Fast and you can bug quite some people that are involved with this thing on SO.. ;-)

Let me exploit Marc's project site: Performance is quite acceptable..

like image 45
Benjamin Podszun Avatar answered Oct 05 '22 10:10

Benjamin Podszun