public static void Add(string InputKey, string InputString, List <Character> _characters) { JObject j1 = JObject.Parse(InputString); JArray myfl; string mychartype; if (j1.SelectToken("firstline") != null && j1.SelectToken("firstline").HasValues) { myfl = (JArray)j1.SelectToken("firstline"); string[] type_array = myfl[0].ToString().Split(default(string[]), StringSplitOptions.RemoveEmptyEntries); mychartype = type_array[2]; } else { myfl = null; mychartype = null; } _characters.Add(new Character { _CharId = Convert.ToInt32(InputKey), _First_Line = myfl[0].ToString(), _Char_Type = mychartype, _PlayerId = 0, _Item_List = JSON.list_Token(j1, "il"), _Defend_List = JSON.list_Token(j1, "ad"), _Hostile_List = JSON.list_Token(j1, "ah"), _Neutral_List = JSON.list_Token(j1, "an"), Accumulated_Weight = 0, Accumulated_Riding_Cap = 0, Accumulated_Men = 0, Accumulated_Land_Cap = 0, Accumulated_Flying_Cap = 0, Ultimate_Lord = 0, _CH_Attack = JSON.int_Token(j1, "CH.at"), _CH_Behind = JSON.int_Token(j1, "CH.bh"), _CH_Break_Point = JSON.int_Token(j1, "CH.bp"), _CH_Contact = JSON.list_Token(j1, "CH.ct"), _CH_Defense = JSON.int_Token(j1, "CH.df"), _CH_Guard = JSON.int_Token(j1, "CH.gu"), _CH_Health = JSON.int_Token(j1, "CH.he"), _CH_LOY_Kind = JSON.int_Token(j1, "CH.lk", -2), _CH_Lord = JSON.int_Token(j1, "CH.lo"), _CH_LOY_Rate = JSON.int_Token(j1, "CH.lr"), _CH_Missile = JSON.int_Token(j1, "CH.mi"), _CH_NPC_Unit_Type = JSON.int_Token(j1, "CH.ni"), _CH_Prisoner = JSON.int_Token(j1, "CH.pr"), _CH_Rank = JSON.int_Token(j1, "CH.ra"), _CH_Sick = JSON.int_Token(j1, "CH.si"), _CH_Skills_List = JSON.list_Token(j1, "CH.sl"), _CM_Appear_Common = JSON.int_Token(j1, "CM.cm"), _CM_Auraculum = JSON.list_Token(j1, "CM.ar"), _CM_Cur_Aura = JSON.int_Token(j1, "CM.ca"), _CM_Hide_Self = JSON.int_Token(j1, "CM.hs"), _CM_Magician = JSON.int_Token(j1, "CM.im"), _CM_Max_Aura = JSON.int_Token(j1, "CM.ma"), _CM_Pledged_To = JSON.int_Token(j1, "CM.pl"), _CM_Already_Visioned = JSON.list_Token(j1, "CM.vi"), _CM_Vision_Protect = JSON.int_Token(j1, "CM.vp"), _LI_Here_List = JSON.list_Token(j1, "LI.hl"), _LI_Where = JSON.int_Token(j1, "LI.wh"), _MI_Cmd_Allow = JSON.string_Token(j1, "MI.ca"), _MI_Garrison_Castle = JSON.int_Token(j1, "MI.gc") }); var Character = (_characters.Find(x => x._CharId == Convert.ToInt32(InputKey))); if (Character != null) { if (Character._CharId.Equals(Convert.ToInt32(InputKey))) { if (j1.SelectToken("na") != null && j1.SelectToken("na").HasValues) { JArray myna; myna = (JArray)j1.SelectToken("na"); Character._Name = myna[0].ToString(); } else { if (Character._Char_Type.Equals("garrison")) { Character._Name = Character._Char_Type.First().ToString().ToUpper() + Character._Char_Type.Substring(1); } } } if (j1.SelectToken("tl") != null && j1.SelectToken("tl").HasValues) { JArray mytl; List <int> mytla; mytl = (JArray)j1.SelectToken("tl"); mytla = mytl.ToObject <List <int> >(); Character._Trade_List = mytla.ToList(); } } }