Skip to content

Instantly share code, notes, and snippets.

@Dynalon
Created October 26, 2012 06:56
Show Gist options
  • Save Dynalon/3957319 to your computer and use it in GitHub Desktop.
Save Dynalon/3957319 to your computer and use it in GitHub Desktop.
ServiceStack DataContract example
using System;
using ServiceStack.Text;
using ServiceStack.ServiceModel.Serialization;
using System.Runtime.Serialization;
namespace Test
{
[DataContract]
public class MyClass
{
[DataMember(Name="some-title")]
public string Title { get; set; }
}
class MainClass
{
public static void Main (string[] args)
{
var mc = new MyClass ();
mc.Title = "Some random title";
var jsd = new JsonDataContractSerializer ();
Console.WriteLine (jsd.SerializeToString (mc));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment