Thrift can not deserialize from json to java object

后端 未结 1 876
忘了有多久
忘了有多久 2021-01-15 19:47

I generated a java object from the following thrift object:

struct Account {
    1: required string accountType,
    2: bool accountActive,
}
相关标签:
1条回答
  • 2021-01-15 20:26

    The SimpleJSONProtocol was never intended to be deserializable. Use TJSONProtocol instead.

    From http://wiki.apache.org/thrift/ThriftUsageJava:

    Serializing to "Simple" JSON

    TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory());
    String json = serializer.toString(work);
    

    The "Simple" JSON protocol produces output suitable for AJAX or scripting languages. It does not preserve Thrift's field tags and cannot be read back in by Thrift.

    (emphasis mine)

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