Using Dictionaries to read out JSON objects is very common but it's much easier to serialize it to a struct or class (which is also built-in to Unity using JsonUtilty.FromJson and JsonUtility.ToJson). Besides being an easier way to handle JSON, this should work on all platforms.
void Start (){
string jsonString = File.ReadAllText(Application.dataPath + "/Resources/Items.json")));
MySpecificData data = JsonUtility.FromJson();
}
public class MySpecificData{
public int id;
public string title;
public int rarity;
public string description;
public string classes;
public string spritelocation;
public int equipslot;
public string prefablocation
public bool stackable;
}
↧