Newtonsoft.Json.DLL 解析Json数据

通过JObject.Parse()解析json字串,然后通过JObject["ITEM1"]["ITEM2"]访问Json数据某个属性的值
        string xml = GetXMLString(); 
        string jsonString = string.Empty; 
        if (xml != string.Empty) 
        { 
            XmlDocument xdoc = new XmlDocument(); 
            xdoc.LoadXml(xml); 
            XmlNode parentNode = xdoc.SelectSingleNode("DATA"); 
            jsonString = JsonConvert.SerializeXmlNode(parentNode); 
        } 

        Aspose.Cells.Workbook xlBook = new Aspose.Cells.Workbook(); 
        xlBook.Open(_fileName); 
        
        //企业基本信息 
        Aspose.Cells.Worksheet sheet = xlBook.Worksheets["企业基本信息"]; 
        int titleRows = sheet.Cells.Rows.Count; 
        JObject jo = JObject.Parse(jsonString); 
         //JObject jo = (JObject)JsonConvert.DeserializeObject(jsonString);           
        sheet.Cells[0,0].PutValue(jo["DATA"]["BASIC"]["ITEM"]["ENTNAME"]==null?"":jo["DATA"]["BASIC"]["ITEM"]["ENTNAME"].ToString()); 


 
 

你可能感兴趣的:(Newtonsoft.Json.DLL 解析Json数据)