using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Collections.ObjectModel;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public string code { get; set; }
public string type { get; set; }
public string description { get; set; }
public class PaymentSource
public List<int> paymentSourceIds { get; } = new List<int>();
[JsonProperty("paymentSourceId")]
int paymentSourceIdAccumulator
paymentSourceIds.Add(value);
public List<PaymentSource> paymentSources { get; set; }
public Status status { get; set; }
public Response response { get; set; }
public static void Test()
var json = "{ \"status\":{ \"code\":\"0\", \"type\":\"SUCCESS\", \"description\":\"Success\" }, \"response\":{ \"paymentSources\":[ { \"paymentSourceId\":176031595, \"paymentSourceId\":176031680, \"paymentSourceId\":162296191, \"paymentSourceId\":160385602, \"paymentSourceId\":160317027 } ] } }";
Console.WriteLine("\nResult of parsing with Json.NET:");
Console.WriteLine(JToken.Parse(json));
Console.WriteLine("\nResult of parsing with System.Text.Json.JsonDocument:");
using var doc = System.Text.Json.JsonDocument.Parse(json);
Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(doc.RootElement, new System.Text.Json.JsonSerializerOptions { WriteIndented = true }));
var root = JsonConvert.DeserializeObject<Root>(json);
Console.WriteLine("\nResult of deserializing and re-serializing {0}:", root);
Console.WriteLine(JsonConvert.SerializeObject(root, Formatting.Indented));
public static void Main()
Console.WriteLine("Environment version: {0} ({1})", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , GetNetCoreVersion());
Console.WriteLine("{0} version: {1}", typeof(JsonSerializer).Assembly.GetName().Name, typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");
public static string GetNetCoreVersion()
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly;
var assemblyPath = assembly.Location.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
return assemblyPath[netCoreAppIndex + 1];