This question was
closed Jul 28, 2018 at 08:44 AM by
this_Jamal for the following reason:
The question is answered, right answer was accepted
Question by
this_Jamal · Jul 28, 2018 at 08:25 AM ·
c#unity5jsonserializeserializable
How to read array json file?
my json;
{
"number":[
{"x":439.0,"y":234.0,"z":342.0},{"x":1.0,"y":2.0,"z":3.0}
]
}
How can I get x value?
I tried:
public class test : MonoBehaviour {
string path;
string jsonString;
void Start () {
path = Application.streamingAssetsPath + "/data.json";
jsonString = File.ReadAllText(path);
Creature Lines = JsonUtility.FromJson<Creature>(jsonString);
Debug.Log(Lines.number[0]);
}
}
[System.Serializable]
public class Number{
public float x;
public float y;
public float z;
}
[System.Serializable]
public class Creature{
public Number[] number;
}
Comment
Follow this Question
Related Questions
Get Yelp API via Oauth in Unity- signature help needed 2 Answers
2D EndlessRunner Spike Placing 0 Answers
unity3d 5 game on fullscreen shows only half of game screen 4 Answers
error CS0201 1 Answer