wxJSON was (is?) also a reasonable implementation.
--
To unsubscribe, send email to wx-dev+un...@googlegroups.com
or visit http://groups.google.com/group/wx-dev
On Wed, 23 Mar 2016 15:08:48 +0200 Eran Ifrah wrote:
EI> For couple of years now, I found myself keep writing wrappers for parsing
EI> and writing JSON objects for my usage with my various wxWidgets projects.
Why is it necessary to wrap anything? I just use whichever external JSON
library the project is using together with wxWidgets.
EI> I would like to suggest adding an official support for JSON in wxWidgets
EI> (and I am willing to implement it)
Thanks for offering it but IMO this would only make sense if there were
some real advantage compared to using another JSON parser.
E.g. maybe
integration with wxAny? But I'm not really sure if this makes sense
EI> I wrote a thin wrapper (which I found very useful) around cJSON API (
EI> https://sourceforge.net/projects/cjson/)
I've never used cJSON but I seem to remember that when I looked for a JSON
parser the last time, I saw several mentions of bugs in it, so I'm not sure
if it's a good choice. I mostly used RapidJSON personally and I didn't have
any problems with it. Being header only is pretty convenient too as it can
be just dropped into any existing object without any problems.
So for me the question is really: what's the advantage of having JSON
support in wxWidgets
itself compared to just using RapidJSON (or maybe
another header-only JSON library, it's not the only one)?
Regards,
VZ
On Wed, 23 Mar 2016 19:32:57 +0200 Eran Ifrah wrote:
EI> On Wed, Mar 23, 2016 at 7:03 PM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
EI>
EI> > On Wed, 23 Mar 2016 15:08:48 +0200 Eran Ifrah wrote:
EI> >
EI> > EI> For couple of years now, I found myself keep writing wrappers for
EI> > parsing
EI> > EI> and writing JSON objects for my usage with my various wxWidgets
EI> > projects.
EI> >
EI> > Why is it necessary to wrap anything? I just use whichever external JSON
EI> > library the project is using together with wxWidgets.
EI> >
EI> Why not? the C API is not that great... and given that wxWidgets is a C++
EI> library...
Yes, but why not just use a C++ library in the first place?
EI> Been using cJSON for several years now to communicate with various
EI> Google, YouTube and Facebook API without a single issue so far
All the better, but it does come pretty bad in the "Conformance" section
of https://github.com/miloyip/nativejson-benchmark. In fact you would be
hard-pressed to find any reason to prefer cJSON to other libraries from
looking at this page...
EI> > So for me the question is really: what's the advantage of having JSON
EI> > support in wxWidgets
EI>
EI> Hmm.. for completeness? we could also ask: whats the advantages of having
EI> wxSocket? wxXmlDocument? wxConfig?
I would have absolutely never added wxSocket to wxWidgets today when we
have ASIO
which is incomparably better than it in all aspects.
wxXmlDocument is used by the library itself, to load XRC, so we can't
really do without it. As for wxConfig, back then (in 1997) there was
nothing similar and I don't know if anything exists now.
EI> I prefer to have a single library wrapping my classes without the need to
EI> fetch them from somewhere else
wxWidgets can't have everything. Yes, JSON is simple enough to be just
about borderline (unlike, say, database access or sockets which were both
clearly mistakes...), but I'm really not convinced there is any advantage
in having it inside instead of using an outside library.
EI> > itself compared to just using RapidJSON (or maybe
EI> > another header-only JSON library, it's not the only one)?
BTW, I didn't use it yet but the library which I'd choose to use right now
if I was starting a new project would be this one:
https://github.com/nlohmann/json
It is header-only, its API looks nice, it has good conformance score and
performance numbers and it has an extensive test suite (even using CATCH
which is my favourite unit testing framework nowadays). Try using it
instead of wrapping cJSON, I'd be curious to know if you really find it
less convenient -- and if you do, at least we'll know why.
Regards,
VZ
On Wed, 23 Mar 2016 19:50:07 +0200 Eran Ifrah wrote:
EI> This discussion is going to the wrong place... I used cJSON because this
EI> was the first I found couple of years ago and I never bothered to search
EI> for another JSON library since. I am not fixated on wrapping this one. The
EI> question is in principle "are you willing to accept new JSON wrapper"
EI> It does not have to be cJSON...
So suppose we drop nlohmann/json.hpp under include/wx and tell people to
use it. Would this be enough?
EI> > I would have absolutely never added wxSocket to wxWidgets today when we
EI> > have ASIO
EI>
EI> Which requires using boost
No, it exists as Boost.ASIO and non-Boost standalone library. It does
require OpenSSL though, but this is just the way it is.
EI> This is pretty much basics these days (having JSON support in the library)
I agree in the sense that people probably do expect to find it in wx. But
I also think people are wrong and we should just explain clearly why there
is no need to have JSON support inside wxWidgets itself.
Regards,
VZ
Which requires using boost (which I am using at work...) but its too bloated and I prefer having a single "big" library in my projectsunless I really have too
I would have absolutely never added wxSocket to wxWidgets today when we have ASIO which is incomparably better than it in all aspects.