jsonutility.tojson works but jsonutility.fromjson from the result of jsonutility.tojson does not
I'm attempting to make dialog trees that are read from a json file, and decided the easiest way to figure out what to read should be the result of the tojson, right? example object gets written to json, I use that json as a template to write anything, unity reads my code. However, this does not work, even if i make zero modifications to the template and just copy+paste the template into the file that is read, it still doesn't work, which doesn't make much sense to me.
first i modify the values of the examples in the inspector, then i run the game with "createExample" set to true, then i copy and paste the content of example.txt without editing to dialog.txt, then i set "createExample" to false, then i run it again and get an error. Bug testing has shown me that it is NOT an error with misreading the lines, the lines show up the same way i pasted them when using Debug.Log(), what am I doing wrong here? Why can the result of tojson not be converted back into an object with fromjson
to be specific i get a nullreference exception
Answer by carriemurraythephysicist · Jul 26, 2019 at 08:16 PM
I FIXED IT
i was so stupid i forgot to initialize my dictionary "dialogs", everything was de serializing fine
Your answer
Follow this Question
Related Questions
"SerializationException: Unexpected binary element: 0" on Deserialization of struct 0 Answers
JSON weird deserialization 1 Answer
Deserialize an outside object in Unity 0 Answers
How can I separate serializable class into its own file? 1 Answer
Null Exception while serialize json string into txt file 0 Answers