Im currently using the Boomlagoon JSON parser, but can’t seem to retrieve object values:
string text = “{ "sample" : { "sam" : 23 } }”; ## string to parse
JSONObject json = JSONObject.Parse(text); ## parsed
double number = json.GetNumber(“sam”); ## Here i’m trying to jump into the sample object and retrieve the double value of sam which is 23.
Debug.Log(number);
Essentially I don’t know how to jump into the sample object and retrieve the value associated with sam.
using UnityEngine;
[Serializable]
public class PlayerInfo
{
public string name;
public int lives;
public float health;
public static PlayerInfo CreateFromJSON(string jsonString)
{
return JsonUtility.FromJson<PlayerInfo>(jsonString);
}
// Given JSON input:
// {"name":"Dr Charles","lives":3,"health":0.8}
// this example will return a PlayerInfo object with
// name == "Dr Charles", lives == 3, and health == 0.8f.
}