Hi Jedrzej,
On Tue, Oct 4, 2011 at 12:50 PM, Jedrzej Nowacki
<[email protected]> wrote:
> Hi,
>
> As Thiago already pointed out, we have few (too many) competing
> implementation of JSON parsers, and two different environments (C++ and
> JS/QML) in which they should work. We should have only one implementation
> mainly because we can't allow behavior differences and because of general
> maintenance costs (testing, performance improvements, etc.).
>
> Currently, I do not see obvious winner. For QML, V8 implementation may be
> preferred, as it creates a native JS object, which can be used directly from
> a QML application. On other hand from C++ point of view it would be an
> overkill to start full JS environment to parse a tiny json file. But of
> course everyone will use QML, so it is not a problem, right :-)? What I do
> not like about qjsonparser mentioned by Girish, is that it uses QVariant as
> a type for object storage. It won't be fast, ever. QVariant is a type safe
> replacement for void*, and nothing more. I think it is misuse to treat it as
> a correct object representation. In Qt, we already have two classes, which
> takes that responsibilities; QObject and QJSValue. The first should be known
> to everyone, second represents a JS object. Another issue related to
> QVariant is that it always needs to be converted to something, in a common
> case you need to iterate over QVariantMap to create an useful
> representation.
>
Right, we are sort of "reusing" QVariant to store the entire json
structure since it incidentally happens to support all the types that
appear in json :) So, maybe we can make the return value be
JsonObject. You can then say:
JsonObject map = obj.map("foo");
int someInt = obj.intValue("bar");
JsonArray arr = obj.array("baz");
(After I wrote this, I see that this is basically very similar to
http://developer.android.com/reference/org/json/JSONObject.html)
If we can agree to the above, then I can create a MR.
> I think we need more benchmarks, before we can make the right decision.
>
I can benchmark my implementation against the others, if the owners
can first tell me that it is completely standards compliant (encoding
detection etc). I have benchmarked against qjson and it's way faster.
The benchmark results are in the qjsonparser repo.
Girish
_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback