1

I have the following code which prints out json to my page

http://screencast.com/t/ASe6sUW64R1

the code is as follows

public async Task<ActionResult> TestRestCall()
        {
            Uri serviceRoot = new Uri(azureAdGraphApiEndPoint);
            var token = await GetAppTokenAsync();
            string requestUrl = "https://graph.windows.net/mysaasapp.onmicrosoft.com/users?api-version=2013-04-05";

            HttpClient hc = new HttpClient();
            hc.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(
                "Bearer", token);

            HttpResponseMessage hrm = await hc.GetAsync(new Uri(requestUrl));

            if (hrm.IsSuccessStatusCode)
            {
                ViewBag.Message = JObject.Parse(await hrm.Content.ReadAsStringAsync()).ToString(Formatting.Indented) ;
                return View();
            }
            else
            {
                return View();
            }

        }

However for debugging purposes, I would like to show the JSON nicely to read it better, but code is not working as I found in another SO answer

1

2 Answers 2

2

You can use https://github.com/umbrae/jsonlintdotcom/blob/master/c/js/jsl.format.js to render json nicely. As it says:

jsl.format - Provide json reformatting in a character-by-character approach, so that even invalid JSON may be reformatted (to the best of its ability).

Or https://stackoverflow.com/a/8007860/250849

Sign up to request clarification or add additional context in comments.

Comments

1

Possible, Postman is what you need. It will render your json in readable format.Also it's a nice debugging tool.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.