using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public class ApiResponse<T> where T : class
public bool Errors { get; set; }
public T Response { get; set; }
public class ApiPagingResponse<T> : ApiResponse<T> where T : class
public class GetBalanceListResponse
public List<GetBalanceListResponseEntity> Entities { get; set; }
public class GetBalanceListResponseEntity
public GetBalanceListResponseEntity([JsonProperty("currency_id")]string currencyId, [JsonProperty("balance")]string balance, [JsonProperty("address")]string address)
Balance = decimal.Parse(balance, NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint,
CultureInfo.InvariantCulture);
[JsonProperty("currency_id")]
public string CurrencyId { get; set; }
[JsonProperty("balance")]
public decimal Balance { get; set; }
[JsonProperty("address")]
public string Address { get; set; }
public static void Test()
Console.WriteLine("\nDone.");
public static void Test(string json)
Console.WriteLine("\nInput JSON: ");
var root = JsonConvert.DeserializeObject<ApiPagingResponse<GetBalanceListResponse>>(json);
var json2 = JsonConvert.SerializeObject(root, Formatting.Indented);
Console.WriteLine("Deserialized and re-serialized JSON: ");
Console.WriteLine(json2);
static string GetSimpleJson()
public static void Main()
Console.WriteLine("Environment version: " + Environment.Version);
Console.WriteLine("Json.NET version: " + typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");
public class AssertionFailedException : System.Exception
public AssertionFailedException() : base() { }
public AssertionFailedException(string s) : base(s) { }
public static class Assert
public static void IsTrue(bool value)
public static void IsTrue(bool value, string message)
throw new AssertionFailedException(message ?? "failed");