Load Data from JSON file
In previous section, i have already introduce json and how to save it ~ Saving Data as JSON in Unity. For now, i will tell you the way to load json.
After you save the json file, you should know how to load it, somehow you want to use it to load some variable after you save your game data. Example, we have the json file from the tutorial before, then we want to load it.
Preparation
Save the PotionData.json and put in StreamingAssets folder.
Before we load, create a new script, I name it LoadData.cs and make the class for load method. Remember, One object, one class!!.
Load the Data!!
After complete the preparation, now create the method for load. Remember, json is text based format, so used ReadAllText method. Because sometimes I missed or wrong in the path where json file is, i recommend using System.IO.Path.Combine method.
.NET provides in its System.IO namespace the Path class which performs operations on String instances that contain file or directory path information. These operations are performed in a cross-platform manner. — http://taswar.zeytinsoft.com/c-tip-use-path-combine-file-directory-path-information/
So, LoadData.cs should be like this
For the last, attach the script in GameObject, Play the scene and see the console.
Conclusion
When you want to load or save json in unity, unity has already provided the class to handle. You can see in unity manual — https://docs.unity3d.com/Manual/JSONSerialization.html