thrift-protocol

Thrift - converting from simple JSON

六月ゝ 毕业季﹏ 提交于 2019-12-09 06:27:21
问题 I created the following Thrift Object: struct Student{ 1: string id; 2: string firstName; 3: string lastName } Now I would like to read this object from JSON. According to this post this is possible So I wrote the following code: String json = "{\"id\":\"aaa\",\"firstName\":\"Danny\",\"lastName\":\"Lesnik\"}"; StudentThriftObject s = new StudentThriftObject(); byte[] jsonAsByte = json.getBytes("UTF-8"); TMemoryBuffer memBuffer = new TMemoryBuffer(jsonAsByte.length); memBuffer.write(jsonAsByte

Thrift JS compatibility with Cassandra (JSON Protocol)

北战南征 提交于 2019-12-08 02:43:25
问题 I have generated a Thrift lib for Cassandra targeting JavaScript from the latest Thrift build in SVN. However, I noticed in the provided js thrift client library the following statement: This client can only speak the JSON Protocol and the only supported transport is AJAX. Does anyone know if the JSON protocol is compatible with Cassandra? The transport is not an issue as I am planning on porting this to use a node.js socket, but I need to know if the JSON Protocol is going to allow me to

Convert an object to a JSON string with thrift json serialization

时光总嘲笑我的痴心妄想 提交于 2019-12-07 01:52:32
问题 I'm new to the thrift. I need to convert my data object to a JSON string with Thrift JSON serialization. I tried in this way. TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory()); String json = serializer.toString(object_name); In here is an error, that object_name should be in TBase . How can I resolve this ? 回答1: In here is an error, that object_name should be in TBase. Next time, please post the exact error message (use copy+paste), this makes it easier for all of us

Convert an object to a JSON string with thrift json serialization

无人久伴 提交于 2019-12-05 06:22:59
I'm new to the thrift. I need to convert my data object to a JSON string with Thrift JSON serialization. I tried in this way. TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory()); String json = serializer.toString(object_name); In here is an error, that object_name should be in TBase . How can I resolve this ? In here is an error, that object_name should be in TBase. Next time, please post the exact error message (use copy+paste), this makes it easier for all of us. How can I resolve this? Whatever you want to serialize with Thrift, must be an descendant of Thrift's

How to use java built-in exception in Thrift IDL

孤人 提交于 2019-12-04 22:28:10
I'd like to throws some java built-in exception such IOException in the Thrift IDL. like this: service B{ void removeLease() throws (1:ioexception e), } however, the Thrift compiler warns that ioexception doesn't be defined. Every java exception is serializable, so it's possible to wrap it into thrift exception. Thrift code: exception SerializedException { 1: required binary payload } service MyService { int method(1: required string param) throws (1: SerializedException serializedException); } Java server code: class MyServiceImpl implements MyService.Iface { int method(String param) throws

Thrift can not deserialize from json to java object

泪湿孤枕 提交于 2019-12-04 02:01:36
问题 I generated a java object from the following thrift object: struct Account { 1: required string accountType, 2: bool accountActive, } I wrote a java code trying to serialize java object to json string and then deserialize the json string back to java object. I can serialize successfully but failed to deserialize. TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory()); TDeserializer deserializer = new TDeserializer(new TSimpleJSONProtocol.Factory()); Account a1 = new

Erlang Universal Binary Format? Anyone using it?

 ̄綄美尐妖づ 提交于 2019-12-03 09:45:24
问题 I recently stumbled upon this 2002 conference paper ( Getting Erlang to talk to the outside world by Joe Armstrong) and I was wondering whether this is a standard that was ignored or if there was any adoption? Should I focus on Apache Thrift for inter-platform communication? (whatever solution I choose will involve at least Erlang) 回答1: You might find the following information helpful about UBF (i.e. UBF User's Guide). http://ubf.github.com/ubf/ubf-user-guide.en.html This might help answer

Thrift - converting from simple JSON

狂风中的少年 提交于 2019-12-03 09:06:06
I created the following Thrift Object: struct Student{ 1: string id; 2: string firstName; 3: string lastName } Now I would like to read this object from JSON. According to this post this is possible So I wrote the following code: String json = "{\"id\":\"aaa\",\"firstName\":\"Danny\",\"lastName\":\"Lesnik\"}"; StudentThriftObject s = new StudentThriftObject(); byte[] jsonAsByte = json.getBytes("UTF-8"); TMemoryBuffer memBuffer = new TMemoryBuffer(jsonAsByte.length); memBuffer.write(jsonAsByte); TProtocol proto = new TJSONProtocol(memBuffer); s.read(proto); What I'm getting is the following

Erlang Universal Binary Format? Anyone using it?

我的梦境 提交于 2019-12-03 00:23:50
I recently stumbled upon this 2002 conference paper ( Getting Erlang to talk to the outside world by Joe Armstrong) and I was wondering whether this is a standard that was ignored or if there was any adoption? Should I focus on Apache Thrift for inter-platform communication? (whatever solution I choose will involve at least Erlang) You might find the following information helpful about UBF (i.e. UBF User's Guide). http://ubf.github.com/ubf/ubf-user-guide.en.html This might help answer some of your questions about UBF. There is also an Erlang server and client implementation of Thrift using the

Can generate .thrift files from existing java/scala interfaces and data types?

两盒软妹~` 提交于 2019-11-30 16:06:58
问题 Is there an easy way to take existing Java/scala datatypes and API interfaces and produce corresponding .thrift files? Having Thrift generate server data structures is excessively invasive as it has the consequences: I cannot annotate my data structures (e.g. for, XML, JSON, hibernate persistence, ...) this pattern conflicts with other serialization frameworks that want to own, or require modification of my source files. As a result, its seems like thrift forces itself into being the