Created
October 26, 2012 06:56
-
-
Save Dynalon/3957319 to your computer and use it in GitHub Desktop.
ServiceStack DataContract example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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