thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joseph TechMails <>
Subject Re: Read/write version of TSimpleJSONProtocol
Date Wed, 13 Jan 2016 09:55:08 GMT
Thanks, BCG. I went through the docs, pretty detailed! , yet to check the
code in detail. I guess you mean the metadata required (ex: field=1)  is
part of the XML itself, not a separate metadata file. Also, curious to know
how Thrift and XML are used, am guessing XML is for using in webservices ,
and Thrift for the internal services. Please clarify.


On Wed, Jan 13, 2016 at 3:41 AM, BCG <> wrote:

> The main issue probably is that TSimpleJSONProtocol erases information
> that is critical to reading uses Thrift's standard semantics; for example
> TSimpleJSONProtocol encodes fields using field names, but when a protocol
> is reading a field it expects a field identifier to be returned.  There are
> other impedance mismatches as well - such as protocols reading
> maps/lists/sets expect for type information and size to be encoded at the
> start of the collection, otherwise you need to read ahead to determine this
> information dynamically, which could get complicated especially for nested
> structures.
> I ran into these problems a little while back when trying to convert
> between Thrift and XML, and the solution that I've found is to use a
> metadata file to add back in the needed information. I have this working
> for XML, and doing it with JSON would not be conceptually different.  You
> can find my code here (the documentation has not been updated in the last
> few weeks though):
> The build is sort of specific to my environment right now but you can at
> least browse the code... the XSLT that does the heavy lifting is in
> src/main/resources.  If you're dealing with JSON you could replace XSLT
> with transformations coded in whatever language you like, and ascertain the
> metadata you need by using the output of Thrift's JSON generator.  It might
> also be possible in Java to get the metadata via reflection on the
> generated structs, since they have a member variable called _Fields that
> contains that information.
> Good luck! ;)
> On 01/11/2016 11:40 PM, Joseph TechMails wrote:
>> Hi,
>> It's known that TSimpleJSONProtocol is write-only. Is there any reason why
>> a read/write version is not supported and is there an alternate approach
>> to
>> achieve this?  My project has been using TJSONProtocol, but now we need to
>> expose this data for Solr indexing which requires a more readable format.
>> Also, in the docs there's a mention of TDebugProtocol, but i couldn't find
>> it in the java library (libthrift-0.9.3.jar). Can someone share how it
>> looks like ?
>> Thanks,
>> Joseph

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message