How to I make use of an API return from a GET post?

10.09.2024
5
0
I will post this first in English. I have this API request that is a GET request and it returns a massive JSON text. So, what is the easiest way to make the JSON file properly formatted and usable?
This is what the code looks like, by the way, that gets the massive text return.

Shall I repost this in Russian?

code-that-works.png
 
C#:
using System;
using System.IO;
using System.Text.Json;

  string jsonString = "{\"name\":\"John\",\"age\":30,\"cars\":[\"Ford\",\"BMW\",\"Fiat\"]}"; // JSON DATA

        using (JsonDocument document = JsonDocument.Parse(jsonString))
        {
            string formattedJson = JsonSerializer.Serialize(document, new JsonSerializerOptions
            {
                WriteIndented = true
            });

            string filePath = "output.json";

            File.WriteAllText(filePath, formattedJson);

            Console.WriteLine("JSON saved to file: " + filePath);
        }
 
  • Нравится
Реакции: William Thompson
Мы в соцсетях:

Обучение наступательной кибербезопасности в игровой форме. Начать игру!

Курс AD