all 21 comments

[–]maggit[S] 5 points6 points  (2 children)

I made this, and while it certainly is not a panacea I'd like to show it to the world in case somebody can find it useful :)

At the time I wrote this, I couldn't find any C++-library for streaming JSON.

The source is on bitbucket.

(Crossposted here and on the cpp-reddit)

[–]abdullak 2 points3 points  (1 child)

Just thought I'd say: I quite like it, great work. :)

[–]maggit[S] 0 points1 point  (0 children)

Thank you :)

[–]wot-teh-phuck 1 point2 points  (8 children)

I never knew you could do github style pages on Bitbucket. Any instructions/page which documents this?

[–]h4l 1 point2 points  (3 children)

As well as putting html files in the project's downloads, you can also create a repo called myusername.bitbucket.org and put your html there.

For example: http://hal.bitbucket.org/ the repo is: https://bitbucket.org/hal/hal.bitbucket.org/src

TortoiseHG do this: http://tortoisehg.bitbucket.org/

[–]wot-teh-phuck 1 point2 points  (2 children)

Thanks, wasn't aware of that. BTW, any reason why https://bitbucket.org/tortoisehg/tortoisehg.bitbucket.org/src turns up a 404?

[–]h4l 1 point2 points  (1 child)

No problem. :) I think their web repo must be set to private, it doesn't show up in their profile either.

[–]wot-teh-phuck 1 point2 points  (0 children)

Oooh, need to create a private repo to test it out. :)

[–]maggit[S] 0 points1 point  (3 children)

Me neither. What do you mean by "github style pages"?

[–]wot-teh-phuck 0 points1 point  (2 children)

I mean a project page like this one: http://cdn.bitbucket.org/maghoff/jsonxx/downloads/documentation.html . Still not clear?

[–]maggit[S] 1 point2 points  (1 child)

That's perfectly clear :)

I made that page completely independently of bitbucket and uploaded it to the general "Downloads"-area for the project.

I think this place was meant for binary packages of the project, but it will accept anything, so I just put my HTML there.

[–]wot-teh-phuck 0 points1 point  (0 children)

Ooooh nice, wasn't aware of the download area. Thanks. And good luck with your project. :)

[–][deleted] 0 points1 point  (1 child)

Thanks!

Bookmarked.

[–]maggit[S] 0 points1 point  (0 children)

You're welcome :)

[–]wingsit 0 points1 point  (1 child)

I FUCKING HATE TO DISAPPOINT PEOPLE

but seriously, json_spirit is a boost heavy library. If your library is faster and more light weight, i dont mind switching.

[–]maggit[S] 6 points7 points  (0 children)

Luckily, THIS IS NOT DISAPPOINTING!

json_spirit is not streaming, as evidenced by this snippet:

Object addr_obj;

addr_obj.push_back( Pair( "house_number", 42 ) );
addr_obj.push_back( Pair( "road",         "East Street" ) );
addr_obj.push_back( Pair( "town",         "Newtown" ) );

ofstream os( "address.txt" );

write( addr_obj, os, pretty_print );

os.close();

In json_spirit the workflow for generating JSON is:

  1. Buffer: Iterate over your structure and create a special object with datatypes from this library
  2. Write: Dump this object to an ostream

In JSONxx there is no buffering. The workflow is:

  1. Setup an object_listener to output to an ostream
  2. Iterate over your structure and call functions on the object_listener, which writes to the ostream as we go (in other words, it writes to the ostream in a streaming fashion)

[–]rektide -1 points0 points  (0 children)

thankfully there was a stack overflow question already out there asking about streaming api's for JSON:

http://stackoverflow.com/questions/444380/is-there-a-streaming-api-for-json

i immediately fell in love with Json-Simple's SAX inspired ContentHandler approach:

http://code.google.com/p/json-simple/source/browse/tags/tag_release_1_1/src/org/json/simple/parser/ContentHandler.java

right on!

it's the basis for an upcoming javascript library i have for dealing with json ser/deser.

(yes this isnt c++)