Interface returns json (response_data):
{ " Code " :. 1 , " the Message " : null, " Error " : null, " the Data " : { " Tire " : [ " 20 is inch and installation and balancing wheels " , " sun tire installation services [14-15 inch] " , ], " the Beautify " : [ { " Cost " : " 14.00 " , "Price":"14.00", "DefaultPrice":"14.00", "OriginalPrice":"15.00", "DayLimit":98, "ActivityId":null, "ActivityName":null, "StartTime":null, "SalesStrategyType":"Default", " CategoryId " : 160 , " RootCategoryName " : " Norway car stickers " , " RootCategoryId " : 159 , " the Description " : " User " , " ProductName " : " Norway car stickers car stickers " , " PID " : " FU- F-NCT-MD | 1 " , "PKID":760, "CategoryName":"挪车贴", "EndTime":null, "SoldCount":48, "TodaySurplus":98, "ProductCommentRate":4, "BigImageUrl":null, "SmallImageUrl":null }, { "Cost":"9.90", "Price":"9.90", "DefaultPrice":"20.00", "OriginalPrice":"100.00", "DayLimit":1, "ActivityId":"71383419-8811-4f5b-9522-33865214c62e", "ActivityName":"9.9洗车", "StartTime":"2019/06/04 12:22:09", "SalesStrategyType":"Groupon", "CategoryId":4, "RootCategoryName":"美容清洗", "RootCategoryId":1, "Description":", "Vehicle wash dry foam" ProductName " : " Standard Car Wash - five cars " , " PID " : " FU-MD-BZXC-F | 1 " , " PKID " : 482 , " the CategoryName " : " standard car wash " , " EndTime " : " 2020 / 01/06 16:45:00 " , " SoldCount " : 334 , "TodaySurplus":1, "ProductCommentRate":4, "BigImageUrl":null, "SmallImageUrl":null }, { "Cost":"20.00", "Price":"20.00", "DefaultPrice":"20.00", "OriginalPrice":"100.00", "DayLimit":96, "ActivityId":null, "ActivityName":null, "StartTime":null, "SalesStrategyType":"Default", "CategoryId":4, "RootCategoryName":"美容清洗", "RootCategoryId" : 1 , " the Description " : " vehicle " , " ProductName " : " Standard Car Wash - five cars " , " PID " : " FU-MD-BZXC-F | 1 " , " PKID " : 482 , " the CategoryName " : " standard car wash " , " EndTime " : null, "SoldCount":334, "TodaySurplus":96, "ProductCommentRate":4, "BigImageUrl":null, "SmallImageUrl":null }, { "Cost":"11.00", "Price":"11.00", "DefaultPrice":"11.00", "OriginalPrice":"50.00", "DayLimit":10, "ActivityId":null, "ActivityName":null, "StartTime":null, "SalesStrategyType":"Default", "CategoryId":7, "RootCategoryName": " The whole car waxing " , " RootCategoryId " : 2 , " the Description " : " standard car washing, waxing the whole car " , " ProductName " : " Testing 001 " , " PID " : " FU-MD-QCDL-F | 37 [ " , " PKID " : 114 , " the CategoryName " : "Whole car waxing ", "EndTime":null, "SoldCount":82, "TodaySurplus":10, "ProductCommentRate":5, "BigImageUrl":null, "SmallImageUrl":null }, ], "ShopDetail":{"Images":[ "https://img3.tuhu.org/Images/Marketing/Shops/f9c9/8ecc/182e30783031398cf89bee7d_w192_h192.png@600w_600h_100Q.png" ], "ShopCertification":640, "HeaderImage":"https://img4.tuhu.org/Images/Marketing/Shops/681be77a-a591-4425-bfec-3cf57181d51e.jpg@600w_600h_100Q.jpg", "ShopImages":[ "https://img3.tuhu.org//Shop/ShopIntroPics/5c09/8974/8bcb8551fed1869b61abcdc5_w536_h300.jpg", "https://img3.tuhu.org//Shop/ShopIntroPics/d386/e4a4/c031b88a62f5ffefa0e8f28e_w192_h168.jpg" ] ] } }
Beautify extracted under Data, to determine if the name is a standard car wash, then extract the price
code show as below:
[] Is the array
{} Is the object
JSONObject jsonObject = new JSONObject(response_data); JSONObject result = jsonObject.getJSONObject("Data"); JSONArray beautify = result.getJSONArray("Beautify"); for (int i = 0 ; i<beautify.length() ; i++){ JSONObject info = beautify.getJSONObject(i); String categoryName = info.getString("CategoryName"); String price = info.getString("Price"); if(categoryName.equals("标准洗车")){ vars.put("Marketing_Price",price); break;