예제 #1
0
        public static void Main()
        {
            string json = @"{  ""Username"": ""atucker"",  ""Expiration"": new Date(1230422400000),  ""AccessRights"": [    ""Search"",    ""Edit"",    ""Add""  ]}";

            JObject jo   = JObject.Parse(json);
            dynamic user = jo.AsDynamic();

            // Loop through dynamic list of access rights
            foreach (var size in user.AccessRights)
            {
                if (size != null)
                {
                    Console.WriteLine(size);
                }
            }

            user.FullName = "Adam Tucker";

            Console.WriteLine(jo.ToString());

            // Use Dynamic Duck to use our dynamic JSON via a static interface
            AddUser(DynamicDuck.AsIf <IUser>(user));

            Console.ReadLine();
        }