Boost logo

Boost :

Subject: Re: [boost] Interest in a Boost.JSON library?
From: Kirit Sælensminde (kirit.saelensminde_at_[hidden])
Date: 2008-12-26 03:21:37

OvermindDL1 wrote:
> I am also quite sure that I read that JSON, in the current form, only
> stores doubles internally as a number representation, although it
> would be simple to support integers as well. I initially had it try
> to parse out a 64-bit integer first, if that failed it tried to parse
> out a double (with perfect accuracy), if neither were sufficient to
> represent the number then it just stored it as a string to allow the
> user to parse it as they wish (I also had a hook where a custom
> container type could be stored into the variant that accepted a string
> to construct from, such as if using some big number library), but I
> commented all that out and just had it support parsing doubles once I
> read that, helped with the speed of the parsing as well.

I was wondering about doing something very similar. I suppose that
passing in the number parser is an option here.

> For comment parsing, I only say it would be easy in mine because
> Spirit2 grammars are very simple to alter in such ways; once you learn
> Spirit2, you will see why. Also, feel free to contact me directly if
> you want help; I have been dealing with Spirit2 exclusively for quite
> some time now so I have learned it quite well. For IM's, I support
> MSN, Yahoo, ICQ, XMPP (through a couple server's, including anything
> Google's supports, such as GTalk), and a few others, so if you want
> immediate communication, feel free to email me with what you prefer to
> use and I can add you.

Thank you for the offer, I'll do so.

Looking at the Spirit 2 examples it looked like it should be simple
enough to use a skip parser for the comments -- I guess there's probably
one for C++ style comments already that would work perfectly.

> Also, due to my use of variants, and no shared pointers (which I did
> use initially, but it proved rather inefficient, especially in light
> of Spirit2s attribute passing being *vastly* more efficient than in
> Classic Spirit), the method I used has no cycle issues (everything is
> by value, built in-place, a lot more efficient in this design then it
> initially sounds).

I'm using the shared pointers for other reasons in the json objects
themselves, but they should be hidden internally (they're not fully yet)
so it won't be possible to make cycles.

> And yes, Spirit2 is in the latest Boost distribution, and yes, it is
> complete sans documentation. Spirit2x is Spirit2, but just in the
> Spirit SVN, not yet in Boost, and it compiles to the same
> vastly-more-efficient-than-Classic-Spirit code, but also compiles a
> great deal faster (Spirit2, like Classic Spirit, compiles hellishly
> slow). Spirit2x is not yet feature complete. Spirit2x.QI, the parser
> part, is complete, what is lacking is Spirit2x.Karma, the reverse
> parser and such. I took a look at your other parsers, and yes, they
> would be vastly cleaner if reimplemented in Spirit2(x), and I could
> help to help you learn the new syntax, just catch me on IM or what-not
> (for note, just adding OvermindDL1 at, or at, or
> at, and so forth will usually catch me if you just want to
> add me directly, I do not check any of those other emails though, only
> gmail and my own websites email).
> Do note, Spirit2x does have 'some' enhancements, like accepting near
> any callable object for an action and so forth, simplifies code even
> far greater... :)

Yes, I saw that in the examples -- very nice :)

All I need to do then I think is to work out how to get Spirit2x on my
include path so that it occludes the Spirit2 library that ships with
Boost and I should be good to go.


Boost list run by bdawes at, gregod at, cpdaniel at, john at