< .Net Core

.Net Core JSON

Szerző: Sallai András

Copyright © Sallai András, 2022

Licenc: CC Attribution-Share Alike 4.0 International

Web: https://szit.hu

Telepítés

Windowson NuGet-tel:

Install-Package Newtonsoft.Json

Linuxon:

dotnet add package Newtonsoft.Json

Használat

class Employee { public string name; public string city; public Employee(string name, string city) { this.name = name; this.city = city; } }
using Newtonsoft.Json; Console.WriteLine("JSON"); List<Employee> employees = new List<Employee>(); employees.Add(new Employee("Park Imre", "Szolnok")); employees.Add(new Employee("Lenti Béla", "Szeged")); employees.Add(new Employee("Orosz Károly", "Hatvan")); employees.Add(new Employee("Pinti József", "Szolnok")); var json = JsonConvert.SerializeObject(employees); Console.WriteLine(json);