[haiku-commits] Re: haiku: hrev47162 - src/apps/haikudepot

  • From: Jonathan Schleifer <js-haiku-commits@xxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 26 Apr 2014 22:11:49 +0200

Am 25.04.2014 um 23:13 schrieb Stephan Aßmus <superstippi@xxxxxx>:

> Did you really just question my decision to roll my own JSON builder and now 
> you tell me you did just that yourself? Why did you roll your own back when 
> you did? :-P

I wrote it because there wasn't any for my Objective-C framework :P. And 
binding a C one seemed like a bad idea because 1.) I wanted it integrated into 
the framework 2.) map it to ObjC objects :P. Which is quite handy now, as I 
mostly only have to swap the code that generates objects with code that 
generates BMessages ;).

> If you have some JSON code written you want to contribute, please, by all 
> means, send them my way! I'd love to have a look.

Added to my TODO :). Any proposals for the API? I hope you don't need 
streaming-capabilities, as it's currently not built for streaming. Though I 
thought about changing that (it's mostly adding a state struct and using that 
struct instead of local variables. And some buffering, of course.)

> I just find it more generic and robust, and I can store the response in a 
> cache too that way. Many JSON libs seem to offer a way to convert actual C++ 
> objects into JSON. This approach can have benefits, but I didn't want to go 
> this route for now. I don't have very good experience with this.

Yes, mapping them to native C++ objects is one way. Though that often makes it 
inconvenient to re-build JSON from them. Mapping to objects of special classes 
seems to be what most parsers do for that reason.

> I have not looked into MessagePack, and apparently neither has Andrew, who is 
> working on the Haiku Depot Server. You could join the haiku-depot-web mailing 
> list on freelists.org, if you want to participate. We could sure use more 
> help.

I don't know what the backend uses, but there are bindings / implementations 
for almost all languages. Thus switching from JSON to MessagePack is often 
quite easy, as the libraries / bindings usually offer the same / a similar API 
than JSON libraries for the same langauge.

I have to say I'm not familiar enough with haiku-depot-web (I think I only saw 
it once in my browser and then never had any contact anymore with it ;)), so 
can't really say anything about that, only that in general using MessagePack is 
as easy as using JSON, with the benefit of having binary types (and with the 
new spec even custom per-protocol types).

--
Jonathan

Other related posts: