Relate two arraylist in android -


user can add items cart , simultaneously url fired , json returned..user can add number of products..each product has unique product_id.now each product can have many suppliers..suppliers have unique supplier_id..for items added cart supplier may common few..say have 5products cart and..supllier1(having unique id) supplies 3products , supplier2(having unique id) supplies 2products..now have found out , added unique supplier_id's in array list..in each json object there field called price..i have add prices unique supplier..so 2suppliers 2 seperate prices shown..(1st supplier1 adding prices of 3products supplies)and other supplier2.. part of json is

   {       "basketitemid": "4455",       "basketid": "11",       "productid": "12909",       "qty": "1",       "supplierid": "7",       "code": "end10-001",       "name": "endo stoppers (100)",        "price": "5.72",       "gst": "0.64",       "pricegst": "6.36",       "brand": "dent america",       "thumbnail": null,      },     {       "basketitemid": "4464",       "basketid": "11",       "productid": "12914",       "qty": "1",       "supplierid": "7",       "code": "ins52-361",       "name": "amalgam gun cvd 45' plastic",        "price": "17.00",       "gst": "1.70",       "pricegst": "18.70",       "brand": "larident",       "thumbnail": null,      },     {       "basketitemid": "4465",       "basketid": "11",       "productid": "13863",       "qty": "1",       "supplierid": "5",       "code": "9516068",       "name": "tofflemire bands #3 0015 pkt 12",        "price": "2.24",       "gst": "0.22",       "pricegst": "2.47",       "brand": "rand",       "thumbnail": null,      }, 

so how can add prices?

if problem revolves around parsing json array may want check out example here. filter supplier, feel free let me expand if want make requirements more explicit.

it (not tested)

integer id; map<integer, double> sums; ... while (reader.hasnext()) {    string name = reader.nextname();    if (name.equals("supplierid")) {      id = reader.nextint();    } else if (name.equals("price")) {      if(!sums.containskey(id)){         sums.put(id, reader.nextdouble());      }      else{        double f = (double) sums.get(id);        sums.put(id, f+reader.nextdouble());      }    } else {      reader.skipvalue();    } } 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -