public static Component Deserialize(string json) { string json_ToImport = json; // Auto-migrate Structural Interfaces Dictionary <String, String> d_ToAutoMigrate = new Dictionary <string, string>() { { "\"AVM.META.StructuralInterface\"", "\"AVM.StructuralInterface\"" }, { "\"AVM.META.StructuralInterfaceDatum\"", "\"AVM.StructuralInterfaceDatum\"" }, }; foreach (KeyValuePair <String, String> kvp in d_ToAutoMigrate) { json_ToImport = json_ToImport.Replace(kvp.Key, kvp.Value); } json_ToImport = ProcessJSON.CrawlJSONDictionary(json_ToImport, new ParseSettings() { b_FixIDs = true, operation = Operation.DESERIALIZE, b_ManipulateMode = true }); Component rtn = JsonConvert.DeserializeObject(json_ToImport, typeof(AVM.Component), jss_defaults) as AVM.Component; return(rtn); }
public string Serialize() { this.DDPSpecVersion = "1.2.1"; string json = JsonConvert.SerializeObject( this, Formatting.Indented, jss_defaults ); Dictionary <String, String> d_OldIDToNew = new Dictionary <string, string>(); json = ProcessJSON.CrawlJSONDictionary(json, new ParseSettings() { b_FixIDs = true, operation = Operation.SERIALIZE, b_ManipulateMode = true }, d_OldIDToNew); json = ProcessJSON.RedirectRefs(json, d_OldIDToNew); return(json); }