Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json array of numbers #1

Open
alex-eri opened this issue Jan 28, 2013 · 3 comments
Open

json array of numbers #1

alex-eri opened this issue Jan 28, 2013 · 3 comments

Comments

@alex-eri
Copy link

not works:
JSONListModel {
json:'{"response":[5,467,2943,4424,13033]}'
query: '$.response[*]'
}
with error: QML ListModel: append: value is not an object

@ghost
Copy link

ghost commented Feb 23, 2013

Same error:
JSONListModel {
id: ratesModel
source: "https://mtgox.com/api/1/BTCUSD/ticker"
query: "$.return.high[*]"
}
error: file:///opt/btcmonitor/qml/btcmonitor/JSONListModel.qml:15:32: QML ListModel: append: value is not an object

@ikt
Copy link

ikt commented Aug 10, 2014

So this is confirmation it can't handle arrays?

@tyler-gilbert
Copy link

This is how I handle arrays:

        var jo = objectArray[key];
        if( jo.toString() === "[object Object]"){
            jsonModel.append( jo );
        } else {
            //this is comma separated strings
            var str = jo.toString().split(",");
            for(var i = 0; i < str.length; i++){
                jsonModel.append({ "item": str[i] } );
            }
            break;
        }

The code does a check to see if the data is a classic object. If it isn't an object, it parses it as an array and uses "item" as the key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants