I have JSON with an array of companies. They have an array of products with descriptions and product names. In Unity, I see everything except descriptions and product names. Is there something wrong with the product class?
I have this JSON:
{
"company": [{
"companyName": "samsung",
"products": [
[{
"productName": "samusung1",
"productDescription": "description1"
}],
[{
"productName": "samusung2",
"productDescription": "description2"
}],
[{
"productName": "samusung3",
"productDescription": "description3"
}],
[{
"productName": "samusung4",
"productDescription": "description4"
}]
]
}]
}
Class in Unity:
public class JsonReader : MonoBehaviour
{
public TextAsset companyJson;
[System.Serializable]
public class Company
{
public string companyName;
public Products[] products;
}
[System.Serializable]
public class Products
{
public string productName;
public string productDescription;
}
[System.Serializable]
public class CompanyList
{
public Company[] company;
}
public CompanyList companyList = new CompanyList();
void Start()
{
companyList = JsonUtility.FromJson<CompanyList>(companyJson.text);
}
}
