how can I define a map accept different kind of value in thrift?

风流意气都作罢 提交于 2019-12-01 13:42:10

You would have to create your own Object and list all possible classes in it.

union Object {
   1: string str;
   2: i32 number32;
}

(as I'm not sure how union implementation works in all langs I'd go with struct with all fields optional)

struct Object {
   1: optional string str;
   2: optional i32 number32;
}

and then: map<string, Object>

In Thrift you can't create 'accept all' field, as it could not be fully portable across languages, and that's one of key functionalities of Thrift.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!