Last active
April 15, 2016 11:46
-
-
Save beachside-project/523a503a5f00925b4a9f3b81caaa87b0 to your computer and use it in GitHub Desktop.
jsonDemo_main1
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var shinobu = new Person() | |
{ | |
FirstName = "shinobu", | |
LastName = "oshino", | |
Age = 598, | |
Favorites = new[] { "golden chocolate", "pon de ring" }, | |
Phones = new List<Phone>() | |
{ | |
new Phone() {PhoneNumber = "000-000-111",ModelName = "Lumia"}, | |
new Phone() {PhoneNumber = "111-000-000",ModelName = "Nokia"} | |
} | |
}; | |
//Serialize、シンプル♪ | |
var shinobuJson = JsonConvert.SerializeObject(shinobu, Formatting.Indented); | |
Console.WriteLine(shinobuJson); | |
//Jsonにインデントつけるには... | |
var shinobuJsonWithIndention = JsonConvert.SerializeObject(shinobu, Formatting.Indented); | |
Console.WriteLine(shinobuJsonWithIndention); | |
//Deserializeもシンプル♪ | |
var shinobuModel = JsonConvert.DeserializeObject<Person>(shinobuJson); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment