Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. {
  2. "success": true,
  3. "data": {
  4. "id": "50",
  5. "seo_h1": "",
  6. "name": "Shirt 10001",
  7. "manufacturer": "",
  8. "sku": "",
  9. "model": "10001",
  10. "image": "http://api.yellowskydemo.com/image/cache/data/shirts/7228-500x500.jpg",
  11. "images": [
  12. "http://api.yellowskydemo.com/image/cache/data/shirts/13-500x500.jpg",
  13. "http://api.yellowskydemo.com/image/cache/data/shirts/302-500x500.jpg",
  14. "http://api.yellowskydemo.com/image/cache/data/shirts/5-500x500.jpg",
  15. "http://api.yellowskydemo.com/image/cache/data/shirts/205-500x500.jpg"
  16. ],
  17. "price": "$540.00",
  18. "rating": 0,
  19. "description": "<p>Fasten your fashion belts, for this is the ultimate edit of swanky casual wear by Ralph Lauren! For men who are born with a strong sense of style, the American powerhouse packs a colourful punch with this high-fash collection of shirts and sporty, monogrammed polos.</p>rnrn<p>Fasten your fashion belts, for this is the ultimate edit of swanky casual wear by Ralph Lauren! For men who are born with a strong sense of style, the American powerhouse packs a colourful punch with this high-fash collection of shirts and sporty, monogrammed polos.</p>rn",
  20. "attribute_groups": [],
  21. "special": "",
  22. "discounts": [],
  23. "options": [
  24. {
  25. "name": "Size",
  26. "type": "select",
  27. "option_value": [
  28. {
  29. "image": "http://api.yellowskydemo.com/image/cache/no_image-100x100.jpg",
  30. "price": "$50.00",
  31. "price_prefix": "-",
  32. "product_option_value_id": "17",
  33. "option_value_id": "55",
  34. "name": "L-40",
  35. "quantity": "99"
  36. },
  37. {
  38. "image": "http://api.yellowskydemo.com/image/cache/no_image-100x100.jpg",
  39. "price": "$40.00",
  40. "price_prefix": "+",
  41. "product_option_value_id": "18",
  42. "option_value_id": "57",
  43. "name": "XXL-44",
  44. "quantity": "100"
  45. }
  46. ],
  47. "required": "1",
  48. "product_option_id": "227",
  49. "option_id": "14"
  50. }
  51. ],
  52. "minimum": "1",
  53. "meta_description": "",
  54. "meta_keyword": "",
  55. "tag": "",
  56. "upc": "",
  57. "ean": "",
  58. "jan": "",
  59. "isbn": "",
  60. "mpn": "",
  61. "location": "",
  62. "stock_status": "Out Of Stock",
  63. "manufacturer_id": null,
  64. "tax_class_id": "0",
  65. "date_available": "2014-08-12",
  66. "weight": "0.00000000",
  67. "weight_class_id": "1",
  68. "length": "0.00000000",
  69. "width": "0.00000000",
  70. "height": "0.00000000",
  71. "length_class_id": "1",
  72. "subtract": "0",
  73. "sort_order": "1",
  74. "status": "1",
  75. "date_added": "2014-08-13 12:05:56",
  76. "date_modified": "2015-06-30 11:19:39",
  77. "viewed": "8",
  78. "weight_class": "kg",
  79. "length_class": "cm",
  80. "reward": "0",
  81. "points": "0",
  82. "category": [
  83. {
  84. "name": "Shirts",
  85. "id": "59"
  86. },
  87. {
  88. "name": "Casual Shirts",
  89. "id": "60"
  90. }
  91. ],
  92. "quantity": "99",
  93. "reviews": {
  94. "review_total": "0"
  95. }
  96. }
  97. }
  98.  
  99. JSONObject jsonObject = new JSONObject();
  100. JSONObject dataObject = jsonObject.getJSONObject("data");
  101. JSONArray imagesArray = dataObject.getJSONArray("images");
  102. ArrayList<String> listOfImagesUrl = new ArrayList<>();
  103. for(int i = 0; i < imagesArray.length(); i++)
  104. {
  105. listOfImagesUrl.add(imagesArray.getString(i)); // listOfImages
  106. }
  107.  
  108. JSONArray optionsArray = dataObject.getJSONArray("options");
  109. for(int i = 0; i < optionsArray.length(); i++)
  110. {
  111. JSONObject option = optionsArray.getJSONObject(i);
  112. JSONArray optionsValueArray = option.getJSONArray("option_value");
  113. for(int j = 0 ; j < optionsValueArray.length(); j++)
  114. {
  115. JSONObject optionValueObject = optionsValueArray.getJSONObject(j);
  116. String image = optionValueObject.getString("image");
  117. String price = optionValueObject.getString("price");
  118. String price_prefix = optionValueObject.getString("price_prefix");
  119. //same like this
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement