카테고리 없음
JSON.NET으로 파생 유형 역직렬화
일등하이
2021. 12. 6. 15:37
반응형
https://stackoverflow.com/questions/8513042/json-net-serialize-deserialize-derived-types
Json.net serialize/deserialize derived types?
json.net (newtonsoft) I am looking through the documentation but I can't find anything on this or the best way to do it. public class Base { public string Name; } public class Derived : Base {...
stackoverflow.com
https://gigi.nullneuron.net/gigilabs/deserializing-derived-types-with-json-net/
Deserializing Derived Types with JSON.NET - Gigi Labs
If you’re using Json.NET to serialize objects which involve inheritance hierarchies, there’s a little issue you might run into. Let’s say we have a class Person: …and we also have another class Employee which derives from Person: Then I can writ
gigi.nullneuron.net
var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All };
MonsterInfo info = new WolfInfo(100);
var json = JsonConvert.SerializeObject(info, settings);
Debug.Log(json);
var info2 = JsonConvert.DeserializeObject<MonsterInfo>(json, settings);
Debug.Log(info2 is WolfInfo);
반응형