Parsing JSON with QML

  • Hi,

    I found the best answer to this question in this post: Parsing Json with QML but it is already five years old and I was wondering if there is a better way with QtQuick 2.0.

    There is one issue in particular. If the JSON response is an array the information in the array is lost. This JSON stream:


    Looks like this in the model:


    How can I add the stream to the list model so that z is not lost?

  • Qt Champions 2016

    There has many methods listed in the article. I am not sure which one you mean, but JSON.parse() do not work?

  • Hi,

    I am using the one dridk mentioned. The parsing works fine and I use


    to fill my ListView. Everything is in the ListModel besides z.
    If I do:

        for(var i in jsonObject){
            eventModel.set(i, {"zn":jsonObject[i]["z"][0]})

    z is added as an array. Just like in the JSON object just without the []-brackets.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.