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

前端 未结 9 652
梦毁少年i
梦毁少年i 2020-12-09 04:21

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 c

相关标签:
9条回答
  • 2020-12-09 05:02

    You can use the wox cross platform serialization library (https://github.com/codelion/wox), it is based on native XML serializers for Java and C#.

    0 讨论(0)
  • 2020-12-09 05:02

    I don't believe binary serialization will work as C# and Java have no idea of each others native types.

    0 讨论(0)
  • 2020-12-09 05:03

    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..

    0 讨论(0)
  • 2020-12-09 05:08

    you can use BSON if you really need the data as binary...

    http://bsonspec.org/implementations.html

    0 讨论(0)
  • 2020-12-09 05:09

    I'll echo most of the other answers here as far as Google protocol buffers is concerned. But I ended up using a program called protostuff at the Java end instead of Google's own Java implementation, and I also added the name of the (outermost) class as a prefix to the protocol buffers data to make the data self-describing for deserialization. Details here: https://stackoverflow.com/a/17923846/253938

    0 讨论(0)
  • 2020-12-09 05:10

    The default binary serialization of each language is incompatible so you will not be able to use that.

    There are many cross-language serialization technologies that support Java, C#, and other languages:

    • JSON
    • Thrift
    • Protocol Buffers

    Of these, JSON is not binary but very efficient for a string-based language. Thrift and Protocol Buffers are binary and have a very compact representation.

    0 讨论(0)
提交回复
热议问题