Home General

Why do json dump looks cut off

Why do json dump looks cut off and where is my json response


Comments

  • You are dumping out the WebResponse which includes details of the content but not the actual content itself and you still need to read it using something like

    using (var reader = new StreamReader(response.Content.ReadAsStream()))
    {
        string json = reader.ReadToEnd(); 
        System.Text.Json.JsonDocument.Parse(json).Dump();    
    }
    

    But it is more easier to use GetStringAsync(url); which does this for you - for example

    using (var client = new System.Net.Http.HttpClient())
    {
        var url = "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json";
        var json = await client.GetStringAsync(url);
        System.Text.Json.JsonDocument.Parse(json).Dump();
    }
    
Sign In or Register to comment.