Example #1
0
 public void StringToObject(string str, object obj)
 {
     string      json = @"{
                   'Name': 'Bad Boys',
                   'ReleaseDate': '1995-4-7T00:00:00',
                   'Genres': [
                     'Action',
                     'Comedy'
                   ]
                 }";
     ProductTest m    = JsonConvert.DeserializeObject <ProductTest>(json);
 }
Example #2
0
        public string ObjectToStr()
        {
            ProductTest[] productTest = new ProductTest[] {
                new ProductTest {
                    Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 2
                },
                new ProductTest {
                    Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M
                },
                new ProductTest {
                    Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M
                }
            };

            return(JsonConvert.SerializeObject(productTest));

            return(null);
        }