Search code examples
c#jsonhttpwebrequest

WebRequest returning JSON but with lots of /n/t


Hey all I currently am getting this response back from when I am calling a API call to get user information:

enter image description here

This is AFTER it try's to do the takeOutSpaces function which looks like this:

public string takeOutSpaces(string data)
{
    string result = data;
    char cr = (char)13;
    char lf = (char)10;
    char tab = (char)9;

    result = result.Replace("\\r", cr.ToString());
    result = result.Replace("\\n", lf.ToString());
    result = result.Replace("\\t", tab.ToString());

    return result;
}

So I'm not sure how to go about using something else to try to get rid of all those /n and /t's.


Solution

  • Modifying the takeOutSpaces function make it work:

    public string takeOutSpaces(string data)
    {
       string result = data;
    
       result = result.Replace("\r", "");
       result = result.Replace("\n", "");
       result = result.Replace("\t", "");
    
       return result;
    }