I have 2 List
in my LocationData
class. The first list is: List. The second one is: List>. Whenever I try to convert it to JSON. The first List is being converted successfully, while the List<List<int>>
is not.
//Location data class
public class LocationData{
public List<int> answer_key;
public List<List<int>> clues;
public LocationData (List<int> p_answer_key, List<List<int>> p_clues){
this.answer_key = p_answer_key;
this.clues = p_clues;
}
}
The code below returns JSON: {"answer_key":[5,4,0]}
only and not including the second List
//convert to json
string locationDataJSON = JsonUtility.ToJson (locationData);
Debug.Log ("JSON: "+locationDataJSON);
> clues` is not a simple type. Use `Newtonsoft` version for Unity that is linked from the duplicate answer. That should solve your issue.
– Programmer Nov 28 '17 at 11:22