Created
February 19, 2013 02:31
-
-
Save yujuwon/4982612 to your computer and use it in GitHub Desktop.
This file contains 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
[Serializable] | |
class JsonIn | |
{ | |
internal string function; | |
internal string type; | |
} | |
[Serializable] | |
class JsonOut | |
{ | |
internal string result; | |
internal string content; | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
JsonIn jsonIn = new JsonIn(); | |
jsonIn.function = "test"; | |
jsonIn.type = "test"; | |
// Object to Stream | |
MemoryStream stream = new MemoryStream(); | |
DataContractJsonSerializer dataSerializer = new DataContractJsonSerializer(typeof(JsonIn)); | |
dataSerializer.WriteObject(stream, JsonIn); | |
// Stream to Object | |
stream.Position = 0; | |
JsonIn jsonIn2 = dataSerializer.ReadObject(stream) as JsonIn; | |
stream.Close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment