[Development] Best-practice data type to pass JSON data between C++ and QML

Milian Wolff mail at milianw.de
Thu Aug 8 17:41:53 CEST 2013


On Thursday 08 August 2013 17:12:46 Simon Hausmann wrote:
> On Thursday 8. August 2013 17.04.38 Milian Wolff wrote:
> > On Thursday 08 August 2013 10:44:36 Jedrzej Nowacki wrote:
> > > Have you tried QJSValue? It is a wrapper around js object so in theory
> > > no
> > > conversion is needed
> > 
> > I don't see a way to construct a QJSValue which holds a JSON object.
> 
> I think
> 
> QJSValue value = engine->toScriptValue(jsonObject);
> 
> should work.
> 
> But regardless, conversions are always involved and they suck :(. Best is to
> either do everything on the JavaScript side (often underestimated!) or C++
> side and minimize the communcation as much as possible.

While working on the webchannel (QObject <-> QWebKit bridge) I found that 
doing too much on the JS side can be a serious bottleneck, esp. on embedded 
hardware with slow CPUs.

Anyhow, I'll stick to QVariantMap then, if there's nothing better. With v4 
this might be improved eventually though, no? I.e. there it should be possible 
to share QJson* on both sides, no?

Thanks!
-- 
Milian Wolff
mail at milianw.de
http://milianw.de



More information about the Development mailing list