Question by
DarKanoiDarg · Mar 11, 2017 at 12:04 PM ·
jsonsave data
Json load fail unity
hello im trying to load data with json but i have some errors that i cant solve
using System.Collections.Generic;
using System.Collections;
using UnityEngine;
using System.IO;
public class BaseDeDatos : MonoBehaviour {
public BaseDatosMisiones bd;
void Start()
{
string datos = File.ReadAllText(Application.dataPath + "/Json/primera_mision.json");
bd = JsonUtility.FromJson<BaseDatosMisiones>(datos);
}
public Mision buscarMisionPorNumero(int numero)
{
return bd.baseDatos.Find(Mision => Mision.numero == numero);
}
}
here is the error
ArgumentException: JSON parse error: Missing a name for object member.
UnityEngine.JsonUtility.FromJson[BaseDatosMisiones] (System.String json) (at C:/buildslave/unity/build/artifacts/generated/common/modules/JSONSerialize/JsonUtilityBindings.gen.cs:24)
BaseDeDatos.Start () (at Assets/Scripts/BaseDeDatos.cs:13)
and here is the classes
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
[System.Serializable]
public class Mision
{
public int numero;
public string texto_inicial;
public string texto_en_curso;
public string texto_terminada;
}
[System.Serializable]
public class BaseDatosMisiones
{
public List<Mision> baseDatos;
}
thanks!
Comment
Your answer
Follow this Question
Related Questions
Application.persistentDataPath 0 Answers
Cannot deserialize JSON to new instances of type 'X' 1 Answer
[Error:] Cannot Deserialize JSON to new instances of type ' X ' 1 Answer
Serialize gameobject children behaviours 0 Answers
Prevent user from copying/deleting files stored in PersistentDathPath 0 Answers