How to serialize object's type by jsonutility.
[Serializable] public class FieldValue { public string field; public object value;
public FieldValue(string field, object value) {
this.field = field;
this.value = value;
}
Debug {"target":[{"field":"time"}]}
why not object value;
Answer by agray427 · Jan 16, 2018 at 07:54 PM
I'm pretty sure you can't with JsonUtility. I recommend using Json.NET if you are needing this kind of capability. I wrote an entire article on it. Check it out here: https://graymattertutorials.wordpress.com/2018/01/15/serialization-with-json-net-in-unity-3d/
Answer by Ice_sakura · Jan 18, 2018 at 05:53 AM
thank you for your reply. Yes, my problem has been solved by Json.net.
I'm glad to hear that it has. If you have further question regarding Json.NET, feel free to message me or you can post to the forum and I may come across it, but others might also be familiar with it and help.
Your answer
Follow this Question
Related Questions
How to save data in Game 0 Answers
Json Utilities returns empty object (javascript) 2 Answers
how do you Deserialize JSON in a list? 0 Answers