public void ShowItemInfo(ItemInShopData itemInShop) { string price = itemInShop.Price + ""; nameItem.text = itemInShop.Item.Id + " - " + itemInShop.Item.Name; priceItem.text = "€ " + price.Replace(".", ","); iconImage.sprite = itemInShop.Item.Image.Image; }
IEnumerator GetDataItemsInShop(WWW www) { //Wait for request to complete yield return(www); if (www.error == null) { jsonData = www.text; Debug.Log(jsonData); //Data is in json format, we need to parse the Json. JSONArray jsonArrayItemsInShop = JSONArray.Parse(jsonData); //parse text to array of strings jsonData = jsonData.Replace("[", ""); jsonData = jsonData.Replace("]", ""); jsonDataObjects = jsonData.Split('}'); for (int i = 0; i < jsonDataObjects.Length; i++) { jsonDataObjects[i] = jsonDataObjects[i] + "}"; if (i > 0) { jsonDataObjects[i] = jsonDataObjects[i].Substring(1); } } if (jsonArrayItemsInShop == null) { Debug.Log("No data converted"); } else { for (int i = 0; i < jsonArrayItemsInShop.Length; i++) { foundItemInShop = new ItemInShopData(); //Data is in json format, we need to parse the Json. JSONObject jsonObjectItemInShop = JSONObject.Parse(jsonDataObjects[i]); itemId = Convert.ToInt32(jsonObjectItemInShop["good_id"].Number); GetItem(i); } } } else { Debug.Log(www.error); } }