如何从JSON响应字符串节点 [英] How to remove string node from json response

查看:104
本文介绍了如何从JSON响应字符串节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要得到这个 JSON 无串节点响应在 ASP.net web服务

 <字符串的xmlns =htt​​p://tempuri.org/>
[{BOOKNAME:爱情故事,名:Vave的Microtech公司,电子邮件:anilkumar@vavemicrotechtt.com,手机:918010066285,地址:Sushant塔秒56 ,古尔冈(印度),nearestarea:古尔冈}]
< /串>


解决方案

只要改变方法的返回类型为void 并写入字符串在的Response.Write()方式是这样的。

  [的WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)
公共无效TestMethod的()
{
   //你的实际的Json
   字符串srtJson =[{\\BOOKNAME \\:\\爱情故事\\}];   HttpContext.Current.Response.ContentType =text / html的;
   HttpContext.Current.Response.Write(srtJson);
}

I want to get this JSON response without string node in ASP.net webservice.

<string xmlns="http://tempuri.org/">
[{"bookname":"Love Stories","name":"Vave Microtech","email":"anilkumar@vavemicrotechtt.com","mobile":"918010066285","address":"Sushant tower sec-56, Gurgaon (India)","nearestarea":"gurgaon"},]
</string>

解决方案

Just change the method return type to void and write string with the Response.Write() method like this.

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void TestMethod()
{
   // your actual Json  
   string srtJson="[{\"bookname\":\"Love Stories\"}]";

   HttpContext.Current.Response.ContentType = "text/HTML";
   HttpContext.Current.Response.Write(srtJson);


}

这篇关于如何从JSON响应字符串节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆