Before going to start parsing json. You must
be add reference to both "system.runtime.serialization" and "system.servicemodel.web".
And in this sample i am using http://json2csharp.com/ for
simply building a C# class from JSON formated string. And its very important is
to make class as similar to Json objects. Other wise we will never parse date
properly.
This is time I am going to cover DataContract JSON Serialization using DataContractJsonSerializer. DataContract
JSON Serialization is mostly used by Windows Communication Foundation (WCF)
services, but I will try to apply this approach to Windows Phone 7
environment.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Text;
using System.Runtime.Serialization;
namespace Json_Parsing
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
string jsonString = @"{
'message': 'Success',
'status': '0',
'paramss': [
{
'redirect_url': 'https //www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=EC-87B5001D184562D',
'ack': '',
'transactionTimestamp': 'Thu May 12 06 45 57 EDT 2011'
},
{
'redirect_url': 'https //www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=EC-87B5001D184562D',
'ack': 'Success',
'transactionTimestamp': 'Thu May 12 06 45 57 EDT 2011'

Join the conversation! Your thoughts help the community grow.