Skip to content

Instantly share code, notes, and snippets.

@joehanna
Last active August 10, 2016 02:34
Show Gist options
  • Select an option

  • Save joehanna/730cc57a4e87cb1f692b34237824379c to your computer and use it in GitHub Desktop.

Select an option

Save joehanna/730cc57a4e87cb1f692b34237824379c to your computer and use it in GitHub Desktop.
HelloEmployeeTest
using System;
using Newtonsoft.Json;
using System.Collections.Generic;
public class Employee
{
public Employee(string lastName, string firstName) {
FirstName = firstName;
LastName = lastName;
}
public string FirstName { get; set; }
public string LastName { get; set; }
}
var employees = new List<Employee>();
employees.Add(new Employee("John", "Doe"));
employees.Add(new Employee("Anna", "Smith"));
employees.Add(new Employee("Peter", "Jones"));
var json = JsonConvert.SerializeObject(employees);
Console.WriteLine($"json: {json}");
employees = JsonConvert.DeserializeObject<List<Employee>>(json);
employees.ForEach(x => Console.WriteLine($"First: {x.FirstName} Last: {x.LastName}"));
<?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" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment