Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8654131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:42:37+00:00 2026-06-12T14:42:37+00:00

I am trying to Deserialize a JSON api to c# on WP7. I need

  • 0

I am trying to Deserialize a JSON api to c# on WP7. I need help in doing so. Im sure its an easy fix but i cannot just see it.

The JSON Data looks like this.

{
"chartDate" : 1349564400, 
"retrieved" : 1349816722, 
"entries" : 
[
    {
        "position" : 1, 
        "previousPosition" : 0, 
        "noWeeks" : 1, 
        "artist" : "Rihanna", 
        "title" : "Diamonds", 
        "change" : 
        {
            "direction" : "none",
            "amount" : 0,
            "actual" : 0
        }
    }, 

which translates to the following using http://json2csharp.com/

    public class Change
  {
      public string direction { get; set; }
      public int amount { get; set; }
      public int actual { get; set; }
  }

  public class Entry
  {
      public int position { get; set; }
      public int previousPosition { get; set; }
      public int noWeeks { get; set; }
      public string artist { get; set; }
      public string title { get; set; }
      public Change change { get; set; }
  }

  public class RootObject
  {
      public int chartDate { get; set; }
      public int retrieved { get; set; }
      public List<Entry> entries { get; set; }
  }

In the application when i click the get feed button i am using the following code but it is coming back with the error Cannot Deserilize JSON object into type “System.Collections.Generic.List`1[Appname.RootObject

The following is my C# from Mainpage.cs

using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Reactive;
using Newtonsoft.Json;

namespace JsonDemo
{
  public partial class MainPage : PhoneApplicationPage
  {
    // Constructor
    public MainPage()
    {
  InitializeComponent();
}

private void Load_Click(object sender, RoutedEventArgs e)
{
  var w = new SharpGIS.GZipWebClient();
  Observable.FromEvent<DownloadStringCompletedEventArgs>(w, "DownloadStringCompleted")
    .Subscribe(r =>
    {
        var deserialized = JsonConvert.DeserializeObject<List<RootObject>>(r.EventArgs.Result);
      PhoneList.ItemsSource = deserialized;
    });
  w.DownloadStringAsync(new Uri("http://apiurl.co.uk/labs/json/"));
}

}
}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:42:38+00:00Added an answer on June 12, 2026 at 2:42 pm

    if r.EventArgs.Result returns the (correct) json in question, this should work:

    var deserialized = JsonConvert.DeserializeObject<RootObject>(r.EventArgs.Result);
    

    –EDIT–

    string json = @"{
        ""chartDate"": 1349564400,
        ""retrieved"": 1349816722,
        ""entries"": [{
            ""position"": 1,
            ""previousPosition"": 0,
            ""noWeeks"": 1,
            ""artist"": ""Rihanna"",
            ""title"": ""Diamonds"",
            ""change"": {
                ""direction"": ""none"",
                ""amount"": 0,
                ""actual"": 0
            }
        }]
        }";
    
    var deserialized = JsonConvert.DeserializeObject<RootObject>(json);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to deserialize/serialize a timespan with Newtonsoft.Json.JsonConvert , but when the JSON is
I am trying to deserialize a json data into a model class but I
I am trying to deserialize a json response from a google api, so i
I'm trying to deserialize a json response and am getting the value cannot be
I'm trying to deserialize JSON into a custom object but all my properties are
i'm trying to deserialize a json string pulled from the web using json.net, but
I'm trying to deserialize json to a java entity, but I'm having trouble getting
I'm trying to deserialize json to an object model where the collections are represented
I am trying to deserialize a JSON string into a class instance in Haxe.
I am trying to serialize/deserialize JSON in Android using GSON. I have two classes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.