Open alex-eri opened 11 years ago
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
So this is confirmation it can't handle arrays?
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.
not works: JSONListModel { json:'{"response":[5,467,2943,4424,13033]}' query: '$.response[*]' } with error: QML ListModel: append: value is not an object