Skip to content

Instantly share code, notes, and snippets.

@mythz
Last active October 18, 2018 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mythz/d3ff39c7052b5b0d6e5dfe4d5e570eb9 to your computer and use it in GitHub Desktop.
Save mythz/d3ff39c7052b5b0d6e5dfe4d5e570eb9 to your computer and use it in GitHub Desktop.
test json deserialization
using System;
using System.Linq;
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Text;
var json = "{\"Confirmations\":[{\"ChangeId\":126552616,\"Confirmed\":true}]}";
[Route("/confirmations", "PUT")]
public class PutConfirmed : IReturn<PutConfirmedResponse>
{
#region Public Properties
public List<Confirmation> Confirmations { get; set; }
#endregion Public Properties
}
public class Confirmation
{
#region Public Constructors
public Confirmation()
{
ChangeId = 0;
Confirmed = false;
}
#endregion Public Constructors
#region Public Properties
public int ChangeId { get; set; }
public bool Confirmed { get; set; }
#endregion Public Properties
}
public class PutConfirmedResponse
{
#region Public Properties
public bool IsSucceed { get; set; }
public ResponseStatus ResponseStatus { get; set; }
#endregion Public Properties
}
var dto = json.FromJson<PutConfirmed>();
dto.PrintDump();
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack.Text" version="5.4.0" targetFramework="net45" />
<package id="ServiceStack.Client" version="5.4.0" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="5.4.0" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment