匿名对象
json反射成匿名对象
var list = new List<object>() { new { orderSkuList = new[]//orderSkuList是个数组 { new {name="",age="" }, }, orderCreateTime = "", } }; var Lists = new List<object>() { list }; var objJson = new { code = "", message = "", data = new { rows = Lists,//rows是个数组 total = "" } }; string textJson = "{\"code\":\"1\",\"message\":\"操作成功\",\"data\":{\"rows\":[{\"orderSkuList\":[{\"name\":\"朱凯宾\",\"age\":\"12\"}],\"orderCreateTime\":1662007551000},{\"orderSkuList\":[{\"name\":\"刘备\",\"age\":\"12\"},{\"name\":\"张飞\",\"age\":\"12\"}],\"orderCreateTime\":1662007551000}],\"total\":2126}}"; var jj = JsonConvert.DeserializeAnonymousType(textJson, objJson); Console.WriteLine(jj.code + "\n");
人各有命,上天注定,有人天生为王,有人落草为寇。脚下的路,如果不是你自己的选择,那么旅程的终点在哪,也没人知道。你会走到哪,会遇到谁,都不一定。