That's good news. Thanks! - Rush
On May 13, 2010, at 4:19 PM, Jake Luciani wrote: > JavaScript bindings are checked in and will be released in 0.3. > > > > On May 13, 2010, at 7:10 PM, David Reiss <[email protected]> wrote: > >> I think the Java library has a "TSimpleJsonProtocol" that does something >> like this. >> It shouldn't be too hard to do the same for C++. I think the biggest >> complication >> is that JSON does allow trailing commas. >> >> --David >> >> Rush Manbert wrote: >>> Hi, >>> >>> I have copied and hacked TJSONProtocol.cpp to make a version that just >>> generates standard JSON when an object is written. >>> >>> By this I mean that if I had this struct definition: >>> >>> struct ExtendedStatus { >>> 1: i32 status, >>> 2: i32 state, >>> 3: i32 percentComplete, >>> 4: i32 elapsedMsec, >>> 5: string statusDescription, >>> 6: string exceptionMsg, >>> } >>> >>> my protocol would serialize it as this: >>> >>> {"status":2,"state":5,"percentComplete:40,"elapsedMsec":1200,"statusDescription":"Talking >>> to the server","exceptionMsg:""} >>> >>> (I wrote this by hand, so it might not be totally correct. The point is >>> that it doesn't encode types, etc. It just uses the member names.) >>> >>> If my Javascript side had a standard object prototype definition for >>> ExtendedStatus, then I can serialize C++ thrift classes from C++, transmit >>> them to my Javascript code, and evaluate the JSON to create an >>> ExtendedStatus object and use it. >>> >>> What I'm missing is the code generation for the prototypes. >>> >>> By any chance, has anyone done this already, and would they be willing to >>> share? Otherwise I guess we'll see about hacking the C++ generator to make >>> one, but that means adding a new generator type, or maybe just making the >>> cpp code generator also generate the prototype JS file automatically. >>> >>> Better still, has anyone secretly written the Javascript code generator >>> that would work with the TJSONProtocol implementation? >>> >>> Or does anyone have another idea of how I can achieve this? I have written >>> a few of these by hand, but it's easy to make mistakes and you need to know >>> when the thrift IDL file changes. >>> >>> - Rush
