android - Get values in a JSONArray -


hey have json array

[     {         "id": 1,         "productname": "audi r8",         "description": "the best of audi",         "cost": 1000000,         "rrp": 1500000,         "product_category": [             {                 "id": 1,                 "category": {                     "id": 1,                     "categoryname": "supercars"                 }             },             {                 "id": 2,                 "category": {                     "id": 2,                     "categoryname": "sportscars"                 }             }         ]     },     {         "id": 2,         "productname": "nissan g-tr",         "description": "the best of nissan",         "cost": 950000,         "rrp": 1000000,         "product_category": [             {                 "id": 3,                 "category": {                     "id": 2,                     "categoryname": "sportscars"                 }             }         ]     },     {         "id": 3,         "productname": "volvo s60",         "description": "fast car",         "cost": 1000000,         "rrp": 2000000,         "product_category": [             {                 "id": 4,                 "category": {                     "id": 2,                     "categoryname": "sportscars"                 }             }         ]     },     {         "id": 4,         "productname": "volvo v70",         "description": "a family car",         "cost": 1500000,         "rrp": 2000000,         "product_category": [             {                 "id": 5,                 "category": {                     "id": 3,                     "categoryname": "volvo"                 }             }         ]     },     {         "id": 5,         "productname": "volvo v50",         "description": "swedish car",         "cost": 1000000,         "rrp": 2000000,         "product_category": [             {                 "id": 6,                 "category": {                     "id": 3,                     "categoryname": "volvo"                 }             }         ]     },     {         "id": 6,         "productname": "ford focus",         "description": "a ford car",         "cost": 100000,         "rrp": 150000,         "product_category": [             {                 "id": 7,                 "category": {                     "id": 5,                     "categoryname": "ford"                 }             }         ]     },     {         "id": 7,         "productname": "ford mondeo",         "description": "a big ford",         "cost": 180000,         "rrp": 200000,         "product_category": [             {                 "id": 8,                 "category": {                     "id": 5,                     "categoryname": "ford"                 }             }         ]     },     {         "id": 8,         "productname": "laferrari",         "description": "a fast car",         "cost": 2000000,         "rrp": 3000000,         "product_category": [             {                 "id": 9,                 "category": {                     "id": 1,                     "categoryname": "supercars"                 }             },             {                 "id": 10,                 "category": {                     "id": 2,                     "categoryname": "sportscars"                 }             }         ]     },     {         "id": 9,         "productname": "saab 9-3",         "description": "a car saab",         "cost": 10000,         "rrp": 333300,         "product_category": [             {                 "id": 11,                 "category": {                     "id": 4,                     "categoryname": "saab"                 }             }         ]     } ] 

how value categoryname can save in textview in android? textview category = (textview) productlistitem .findviewbyid(r.id.product_cost);

the whole json object jsonarray right? like

getjsonarray("nameofyourmainarray").getjsonobject(indexoftheobjectyouwant).getjsonarray("product_category").getjsonobject(indexoftheobjectyouwant).getstring("categoryname"); 

keep in mind nameofyourmainarray string , indexoftheobjectyouwant it's integer.

cheers


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -