So I was trying to parse the JSON data into list/array, but kinda stuck at the format like this. I'm relatively new at JSON, so I'm not very good at processing those stuffs
Here's my code:
void processJsonData(string _url)
{
jsonDataClass jsnData = JsonUtility.FromJson<jsonDataClass>(_url); //_url is based on the Json text below
Debug.Log(jsnData.data);
}
I uses this code to see if it managed to get the data from it, but it shows the error like this
The JSON looks like this:
[{"country":"Malaysia","sales":9244},
{"country":"Singapore","sales":3103},
{"country":"Japan","sales":1755},
{"country":"China","sales":7835},
{"country":"United States","sales":2755},
{"country":"United Kingdom","sales":8611},
{"country":"Australia","sales":3877}]
My jsonDataClass
looks like this:
using System.Collections;
using System.Collections.Generic;
using System;
[Serializable]
public class jsonDataClass
{
public List<basicData> data;
}
[Serializable]
public class basicData
{
public string country;
public float sales;
}
>("{\"data\":" + _url+ "}");`
– Mehdi Dehghani Jun 22 '21 at 05:35