Create the array of suppliers and store this collection of suppliers in JSON object using JSON Serialization
using System;
using System.Text.Json;
namespace Test
{
class Supplier
{
public Supplier(string name)
{
Name = name;
}
public string Name { get; private set; }
}
class JsonTest
{
static int Main()
{
Supplier[] suppliers = new Supplier[]
{
new Supplier("Apple"),
new Supplier("Microsoft"),
new Supplier("Intel")
};
JsonSerializerOptions options = new JsonSerializerOptions { WriteIndented = true};
string json = JsonSerializer.Serialize(suppliers, options);
Console.WriteLine(json);
return 0;
}
}
}
Comments
Leave a comment