本文共 740 字,大约阅读时间需要 2 分钟。
.NET 3.5支持读取JSON格式的数据。只要 using System.Runtime.Serialization; using System.Runtime.Serialization.Json; 就可以。这两个命名空间,要添加引用:System.Runtime.Serialization 。
只引用一个System.Runtime.Serialization 是不够的,
还要添加 System.ServiceModel
System.ServiceModel.Web
的引用
读取到XML
HttpWebResponse response = 根据页面地址抓取到的该页面内容,全部是JSON数据。 Stream stream = response.GetResponseStream(); XmlDictionaryReader xmlReader = JsonReaderWriterFactory.CreateJsonReader(stream, XmlDictionaryReaderQuotas.Max); xmlReader.Read(); String XMLString = xmlReader.ReadOuterXml(); stream.Close(); stream.Dispose(); XmlDataDocument doc = new XmlDataDocument(); doc.DataSet.ReadXmlSchema(“json.xsd”);//这个XSD是针对JSON格式写的一个格式文件 doc.LoadXml(XMLString); DataSet ds = doc.DataSet;//获取到数据。
主要是这个XSD该怎么写。
转载地址:https://leftfist.blog.csdn.net/article/details/5889121 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!