Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我开发了一个在线巴士座位预订项目,这里我为每个操作使用 API。
一项操作必须将信息写入.xml文件,现在他们已更改为.json. 我已经从 中获得了价值.xml,但我不知道如何从中获得价值.json。
.xml
.json
这取决于您使用的方法类型。就它们而言,GET您可以从中获得价值Request.QueryString["Key"],如果方法类型是,POST那么您可以从Request.Form["key"]. 要以 Json 格式返回结果,您可以使用.Net 3.0 System.Web.script.Serialization包含 Class 的命名空间来将对象转换为 json 数据JavaScriptSerializer,或者您可以使用一些第三方 dll,例如JSON.NET在处理 json 数据时属于我最喜欢的列表中的 One。
GET
Request.QueryString["Key"]
POST
Request.Form["key"]
.Net 3.0 System.Web.script.Serialization
JavaScriptSerializer
JSON.NET