How to display json data using C#
See original GitHub issueHello 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:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A suggestion by @eerhardt was to make it look more like the JSON displays in browser developer tools:
The first iteration is merged now. I’d like to do another iteration to improve the styling.
Here’s how it looks: