- Home /
Accessing JSON in unityscript
Hello all, really confused about how to access constants stored in a JSON object (code below).
var levelConstants = {
"goldBase": 5,
"goldExp": 1.05,
"healthBase": 10,
"healthExp": 1.07
};
Im then trying to access them and manipulate them in some way for simplicity im trying
Debug.Log(levelConstants["goldBase"] * 5);
But the above gives the following error
BCE0051: Operator '*' cannot be used with a left hand side of type 'Object' and a right hand side of type 'int'.
The problem is unityscript seems to have assigned an object type to levelConstants.goldBase. What is the best way to set the type for variables inside of a json object? Is there somewhere that explains using json in unityscript, as i cannot find much documentation on the process.
Your answer
Follow this Question
Related Questions
Why are JSON Libraries even necessary? Isn't it Native? 1 Answer
Transfer data to/from server in mobile 0 Answers
JsonUtility.ToJson returns empty file 2 Answers
Transfer data to/from server 1 Answer
Streaming Assets android 0 Answers