-1

I want to get data from result and Total Row , but result cant defined it. But when I use api without array Result and TotalRow. I can use it with allProduct[i].name_category and direct to JsonClassPro. But now i want to use with array for make one API. Can anyone help ?

void DrawUI()
{
    for (int i = 0; i < 10; i++)
    {
        GameObject goItems = (GameObject)Instantiate(prefabItems);
        goItems.transform.SetParent(ParentItems, false);
        goItems.transform.GetChild(1).GetComponent <TMPro.TMP_Text>().text = allProduct.Result[i].name_category;
        goItems.transform.GetChild(2).GetComponent <TMPro.TMP_Text>().text = allProduct.Result[i].name;
        goItems.transform.GetChild(3).GetComponent <TMPro.TMP_Text>().text = allProduct.Result[i].price.ToString();
        PlayerPrefs.SetString("IdProduct",allProduct[i].id_product);
        goItems.GetComponent<Button> ().AddEventListener(i, ItemClicked);
    }
}

API

API

lLm003
  • 11
  • 2

1 Answers1

0

Install the Json.Newsoft package and import the reference to the package:

using Newtonsoft.Json.Linq;

Parse the Json string to a 'JObject' like such:

JObject? jsonObject = JObject.Parse(jsonString);

Then parse whatever value you want to an array because I don't know exactly what value you want parsed but i'll give you an example:

JArray? jsonArray = jsonObject["Result"].Value<JArray>();

Or you could do it this way:

IEnumerable<JObject?> results = jsonObject["Result"].Values<JObject>();
Sylas Coker
  • 25
  • 1
  • 7