类转json、 json转xml的方法,转SortedDictionary转 xml 的方法。
接续昨天的问题: json 转换 xml
{"jylsh":null,"testtimes":null,"license":null,"licensetype":0,"Licensecode":null,"Vehicletype":null,"vehiclemodel":null,"cpmc":"88","clscqy":null,"Engine":null,"Enginemanuf":null,"Fdjh":null,"Ed":null,"Enginespeed":null,"Enginepower":null,"Usetype":null,"registerdate":null,"Mdate":null,"Owner":"fdas","lxdh":null,"lxdz":null,"Standard":null,"Gear":null,"Airin":null,"Fuelsupply":null,"Drivemode":null}
试过了也不行。
The root object must have a single property in order to create a valid XML document.
根对象必须有一个属性才能创建有效的XML文档。
json 转字典
var dic = JsonConvert.DeserializeObject<SortedDictionary<string, object>>(json);
SortedDictionary<string, object> keyValues = new SortedDictionary<string, object>(dic);
keyValues.OrderBy(m => m.Value);//升序
//keyValues.OrderByDescending(m => m.Key);//降序
string xmlvalue = JsonConvert.SerializeObject(keyValues);
类 转 sjon
string json = JsonConvert.SerializeObject( 对象);
DBCHM 这个软件好用,看数据结构,生成数据结构。这个软件真的是相见恨晚啊!
Lambda表达式 这个我还有点不会