How to remove d: from json response through c#?

I am consuming asmx web service from Visual studio c#. Sample code

WebRequest request = WebRequest.Create(WholeURL); request.ContentType = "application/json; charset=utf-8"; request.Method = "POST"; request.ContentLength = postData.Length; using (StreamWriter requester = new StreamWriter(request.GetRequestStream())) { requester.Write(postData); requester.Close(); } //Get the response WebResponse response = request.GetResponse(); // Get the stream containing content returned by the server. Stream dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content.ok string responseFromServer = reader.ReadToEnd();

How can i remove d from json response

my json response is : { "d" : -1} i only need -1.

Thanks

-------------Problems Reply------------

I think you just need to parse the JSON, and grab the value at key="d".

Using JSON.NET

string json = @"{""key1"":""value1"",""key2"":""value2""}";
Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);

Console.WriteLine(values.Count); // 2
Console.WriteLine(values["key1"]); // value1

Category:jquery Views:0 Time:2013-03-22

Related post

  • Remove accents from a JSON response 2010-04-29

    I get back a JSON response from a social networks site. There are certain accented characters that I would like to be removed. An example is : L\u00e1szl\u00f3 M\u00e1rton, that reads "László Márton" and I would like to be transformed into Laszlo Mar

  • How to remove response headers when sending a json response in php? 2011-06-02

    I am making an ajax request to a php page e.g page1.php. In page1.php I have a header("Location:page2.php?password=1234") code which redirects to page2.php with the password as a GET parameter. page2.php gives a json response. The problem is that whe

  • How to remove d: and __type from JSON response for ASP web service 2011-12-08

    I've found several solutions for this on the web that are for WCF web service and not ASP web service. Currently, I'm getting back a JSON response that says: {"d":[{"__type":"NetworkFuzzWebSvc.Sessions","BaseUri":"http://localbox","SessionId":"43b871

  • What do I need to escape in my HTML (JSON response) 2009-06-14

    My JSON response looks like: {rc: "200", test: "", user: "<div class='sub1'> <div class='avatar'> <a href='/blah'>blah</a><br /> <strong>0</strong> </div> <div class='sl'> <p> you droppped t

  • Why do people put code like "throw 1; " and "for(;;);" in front of json responses? 2010-06-30

    Possible Duplicate: Why have “while(1);” in XmlHttpRequest response? Why does Google prepend while(1); to their JSON responses? Google returns json like this: throw 1; <dont be evil> { foo: bar} and Facebooks ajax has json like this: for(;;); {

  • Ajax and JSON response bug in Internet Explorer (works in all other browsers) 2010-08-31

    For some reason IE is asking us to download a file instead of running it as ajax. This works in all browsers except IE. I tried messing with the headers that it returns with no luck. The function grabs form data then post's it the response is a can b

  • C# trying to create JSON response but getting HTML in it 2010-11-01

    When I view my response I have my json data but at the bottom i've got the html of the page? I'm trying to create a JSON response any spot something obvious. All i've done is create a blank .aspx page. protected void Page_Load(object sender, EventArg

  • how to get the value from this json response using php 2010-12-23

    i need to extract the exam from this json response using php cb({"data": [{"map": {"exam": ["e", "x", "a", "m"]}, "words": false, "o": ["exam", "exam", "exam"]}]},150) --------------Solutions------------- The problem here is that the answer is wrappe

  • Jettison and JAXB Automatically Changes Data Type in JSON Response 2011-01-20

    I'm using Resteasy 2.0.1.GA and Resteasy-jettison-provider-1.2.GA with JAXB annontations and whenever I have a String property that contains all numbers (i.e. String groupName="1111";), the JSON response will display it as a number by removing the do

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.192 (s). 11 q(s)