2

All attempts to use JsonUtility.FromJson on a json with nested values fail.

How would you turn the following json into an object without creating a class for every nested value?

{
  "Player": {
    "Level": 1
  },
  "Weapons":{
    "BasicWeapon": {
      "Level": 1
    }
  }
}
2
  • I had the same error, everything is returning null right ? If so, try to use JsonConvert.DeserializeObject(yourString) Commented Apr 26, 2019 at 14:54
  • When trying to get Player.Level it returns blank not null. Commented Apr 26, 2019 at 15:11

2 Answers 2

3

use SimplJson Library Like this

JSONNode node = JSON.Parse( jsonString );

string level= node["Player"]["Level"].Value;

Sign up to request clarification or add additional context in comments.

Comments

1

there is also another Library that can Handle that :
https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.