How to access nested array JSON file in blackberry 10 using qml -


i have following json file trying access time, percent, amount above nested array json file using qml. not able these data. want data fill in table has 3 columns. please tell me how it.

sample.json:  {    "rates": [      {        "time": "3 months",        "interest": [          {            "percent": "0.01",            "amount": "2500"          },          {            "percent": "0.02",            "amount": "5000"          },          {            "percent": "0.09",            "amount": "10000"          }        ]      },      {        "time": "6 months",        "interest": [          {            "percent": "0.10",            "amount": "2500"          },          {            "percent": "0.11",            "amount": "5000"          },          {            "percent": "0.12",            "amount": "10000"          }        ]      },      {        "time": "1 year",        "interest": [          {            "percent": "0.11",            "amount": "2500"          },          {            "percent": "0.12",            "amount": "5000"          },          {            "percent": "0.14",            "amount": "10000"          }        ]      }    ]  }

this how load , data. how in table shouldn't hard here

import bb.cascades 1.2 import bb.data 1.0 page {     container {      }     attachedobjects: [         datasource {             id: datasource             source: "sample.json"             type: datasourcetype.json             ondataloaded: {                 console.log(data.rates);                 console.log(json.stringify(data));                 for(var = 0; < data.rates.length; i++){                     console.log(json.stringify(data.rates[i]));                     console.log("time: " + data.rates[i].time);                      for(var j =0; j < data.rates[i].interest.length; j++)                     {                         console.log(json.stringify(data.rates[i].interest[j]));                         console.log("percent: " + data.rates[i].interest[j].percent);                         console.log("amount: " + data.rates[i].interest[j].amount);                     }                 }             }         }     ]     oncreationcompleted: {         datasource.load();     } } 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -