Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Navigation;
- using Microsoft.Phone.Controls;
- using Microsoft.Phone.Shell;
- using PhoneApp5.Resources;
- using Newtonsoft.Json;
- namespace PhoneApp5
- {
- public partial class MainPage : PhoneApplicationPage
- {
- // Constructor
- public MainPage()
- {
- InitializeComponent();
- string jsona = @"[
- {
- 'Name': 'Product 1',
- 'ExpiryDate': '2000-12-29T00:00Z',
- 'Price': 99.95,
- 'Sizes': null
- },
- {
- 'Name': 'Product 2',
- 'ExpiryDate': '2009-07-31T00:00Z',
- 'Price': 12.50,
- 'Sizes': null
- }
- ]";
- List<Product> products = JsonConvert.DeserializeObject<List<Product>>(jsona);
- //Console.WriteLine(products.Count);
- // 2
- Product p1 = products[0];
- Product p2 = products[1];
- MessageBox.Show(p1.Name);
- MessageBox.Show(p2.Name);
- // Product 1
- }
- }
- public class Product
- {
- public string Name { get; set; }
- public DateTime ExpiryDate { get; set; }
- public string Price { get; set; }
- public string Sizes { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement