Skip to content

Instantly share code, notes, and snippets.

@mythz
Created January 19, 2017 20:11
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/32518b6aea880c07d538fde1a974e0b8 to your computer and use it in GitHub Desktop.
Save mythz/32518b6aea880c07d538fde1a974e0b8 to your computer and use it in GitHub Desktop.
Machine JSON DTOs
using System.Linq;
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Text;
public class Dto
{
public int SourceID { get; set; }
public Dictionary<int, MachineEntry> Machines { get; set; }
}
public class MachineEntry
{
public Machine Machine { get; set; }
}
public class Machine
{
public string Version { get; set; }
}
var json = "{\"SourceID\":\"4\",\"Machines\":{\"2017\":{\"Machine\":{\"Version\":\"501\"}}}}";
var dto = json.FromJson<Dto>();
dto.PrintDump();
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack.Text" version="4.0.62" targetFramework="net45" />
<package id="ServiceStack.Client" version="4.0.62" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="4.0.62" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment