- Home /
Question by
austinsheep · Mar 07, 2014 at 07:10 AM ·
saveloadjson
SimpleJSON array problem
Here is my load function to return values from a JSON file.
function load(){
var file = new File.OpenText("save.json");
var array = new Array();
var i : int = 0;
while(true){
var input = file.ReadLine();
if(input == null){
break;
}
array[i] = input;
i++;
}
var parse = JSON.Parse(array.join(""));
file.Close();
if(stan != null){
Application.LoadLevel(parseInt(parse["floor"]));
stan.transform.position.x = parseFloat(parse["x"]);
stan.transform.position.y = parseFloat(parse["y"]);
}
//Here is the problem
enemy = parse["enemies"];
}
I have no problem parsing the ints and floats with parseInt() and parseFloat(), but I have an array in the file named 'enemies'. And I'd like to have my enemy variable which is an int array equal that when I run my load function
Comment
Your answer
Follow this Question
Related Questions
How to save and load any data type? 1 Answer
LitJson load float 2 Answers
Why is JSON not saving my Class? 2 Answers
Saving GameObject to file 2 Answers
Saving/Loading class list with SimpleJSON,Saving class list with SimpleJSON 1 Answer