question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to display json data using C#

See original GitHub issue

Hello there, I’m new to .NET Interactive, and I’m trying to experiment with it, but I haven’t found a simple way to show some json data I got using HttpClient. I’m querying repository issues from the Github api, which returns an array of issues. From there, I’m stuck. This is what I have:

using System.Net.Http;
using System.Net.Http.Headers;
var client = new HttpClient();
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Net_Notebooks", "1.0"));
var response = await client.GetAsync("https://api.github.com/repos/giggio/node-chromedriver/issues");
#r "nuget:Newtonsoft.Json"
var responseString = await response.Content.ReadAsStringAsync();
var issues = Newtonsoft.Json.Linq.JArray.Parse(responseString);
// and now what?

I tried displaying it using JSON.net but it shows jibberish.

dynamic issues = Newtonsoft.Json.JsonConvert.DeserializeObject(responseString);
issues

The value at responseString is correct, it contains a valid json array.

I’m not sure what is the idiomatic way to do this. Any pointers are appreciated.

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jonsequiturcommented, Apr 16, 2021

A suggestion by @eerhardt was to make it look more like the JSON displays in browser developer tools:

image

0reactions
jonsequiturcommented, Apr 28, 2021

The first iteration is merged now. I’d like to do another iteration to improve the styling.

Here’s how it looks:

image

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to write the json-c object into a file using C?
I am able to print jobj on the console by using printf : printf ("%s",json_object_to_json_string(jobj));. Now I need write the jobj data to...
Read more >
Parsing JSON in C using microjson
The microjson library was designed to parse a large subset of JSON into static C structures using only fixed-extent storage. The library is...
Read more >
Examples for the json-c tutorial.
A simple example of json string parsing with json-c. *. * clang -Wall -g -I/usr/include/json-c/ -o json_parser json_parser.c -ljson-c. */. #include <json.h>.
Read more >
How to Parse JSON in C - YouTube
In this step- by -step tutorial, you'll learn how to use a popular library called JSON - C to parse a simple JSON...
Read more >
cJSON - JSON File Write/Read/Modify in C
We then parse the JSON data using the cJSON_Parse() function, which returns a pointer to a cJSON object. If the parsing fails, we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found