关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

Newtonsoft.Json 父亲json 增加儿子json

发布时间:2019-11-06 17:17:45


            //得到fields 的值

            //带不带[]的json用JObject.Pase(json string)来反序列化

            JObject father = JObject.Parse(jsonStr.Replace("[", "").Replace("]", ""));//父亲json

            JObject children = JObject.Parse(json);//儿子json

            JProperty jpropChild = new JProperty("children",children);

            father.Add(jpropChild);



            //反序列化JSON字符串 开头带[]用这个来反序列化

            //JArray ja1 = (JArray)JsonConvert.DeserializeObject(jsonStr);



            //得到fields 的值

            //带不带[]的json用JObject.Pase(json string)来反序列化

            JObject father = JObject.Parse(jsonStr.Replace("[", "").Replace("]", ""));//父亲json

            JObject children = JObject.Parse(json);//儿子json

            JProperty jpropChild = new JProperty("children",children);

            father.Add(jpropChild);



            //反序列化JSON字符串 开头带[]用这个来反序列化

            //JArray ja1 = (JArray)JsonConvert.DeserializeObject(jsonStr);



/template/Home/Zkeys/PC/Static