■ JavaScriptSerializer 클래스 : JSON 직렬화/역직렬화 하기

----------------------------------------------------------------------------------------------------

using System;

using System.Web.Script.Serialization;

 

string jsonString = @"

{

    ""Items"":

    [

        { ""Name"" : ""Apple"" , ""Price"" : 12.3 },

        { ""Name"" : ""Grape"" , ""Price"" : 3.21 }

    ],

    ""Date"" : ""21/11/2010""

}

";

 

JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

 

var instance = javaScriptSerializer.Deserialize<dynamic>(jsonString);

 

string newJSONString = javaScriptSerializer.Serialize(instance);

 

Console.WriteLine(newJSONString);

----------------------------------------------------------------------------------------------------

※ System.Web.Extensions 참조를 설정한다.

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요