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 9187417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:45:45+00:00 2026-06-17T19:45:45+00:00

im trying to deserialize the JSON data Ive retrieved from facebook but c# wont

  • 0

im trying to deserialize the JSON data Ive retrieved from facebook but c# wont allow it because “F.18-24” is an invalid variable when I try to declare it in the public class. I managed to deserialize the ‘metric’ field but for “F.18-24” field, Im not sure how do I go about this. Any help would be appreciated. Is it something to do with Ext.data.Record in order for the c# to read F.18-24?

My JSON data Ive retrieved from facebook:

{"data":[
{
    "metric":"page_fans_gender_age", 
    "value":
        {"F.18-24":19,
        "M.18-24":14,
        "M.25-34":4,
        "F.13-17":1,
        "M.13-17":1
}}]}

And my codes to deserialize:

//geting isights data age & gender
    private void kryptonButton1_Click_2(object sender, EventArgs e)
    {
        try
        {

          var client = new FacebookClient(myToken.Default.token);
          var query = string.Format("SELECT metric, value FROM insights WHERE object_id=132414626916208 AND metric='page_fans_gender_age' AND period = period('lifetime') AND end_time = end_time_date('2013-01-18')");

            dynamic parameters = new ExpandoObject();
            parameters.q = query;
            dynamic results = client.Get("/fql", parameters);

            JavaScriptSerializer sr = new JavaScriptSerializer();
            String jsondata = String.Empty;
            jsondata = results.ToString();

            genderAgeDataII converted = sr.Deserialize<genderAgeDataII>(jsondata);
            Console.WriteLine(converted);
        }

        catch (Exception ex) {
            MessageBox.Show(ex.Message);
        }

    }


}

//class for JSON Deserialize
public class genderAgeDataII
{
    public genderAgeData[] data { get; set; }
}

public class genderAgeData
{
    public string metric { get; set; }
    public genderAge value { get; set; }
}

public class genderAge
{
    //public string numbers { get; set; }
    /*string f1824 = "F.18-24";
    string m1824 = "M.18-24";
    string m2534 = "M.25-34";
    string f1317 = "F.13-17";
    string m1317 = "M.13-17"; */

    public int f1824 { get; set; }
    public int m1824 { get; set; }
    public int m2534 { get; set; }
    public int f1317 { get; set; }
    public int m1317 { get; set; }
}
  • 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-17T19:45:47+00:00Added an answer on June 17, 2026 at 7:45 pm

    FB C# SDK supports generics. You can use it as

    var data = fb.Get<genderAgeDataII>("fql", parameters);
    

    https://github.com/facebook-csharp-sdk/facebook-csharp-sdk/pull/203

    Then use data contracts and datamember

    [DataContract]
    public class genderAge
    {
        //public string numbers { get; set; }
        /*string f1824 = "F.18-24";
        string m1824 = "M.18-24";
        string m2534 = "M.25-34";
        string f1317 = "F.13-17";
        string m1317 = "M.13-17"; */
    
        [DataMember(Name="F.18-24")]
        public int f1824 { get; set; }
        .....
    }
    
    • 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 json data services recieved from a web server into an
I am trying to deserialize a json data into a model class but I
I am trying to parse out data from oodle.com api feed using the JSON.NET
I am trying to deserialize a Json object that I am getting from the
I'm trying to deserialize JSON in this format: { data: [ { installed: 1,
I'm trying to deserialize JSON in this format: { data: [ { installed: 1,
I'm trying to read some data in as Json, deserialize it, and display it
I'm trying to grab some JSON data from a web service using JSON.Net. The
I have a JSON response from Facebook with the following structure: { data: [
I'm trying to deserialize some JSON data into objects for an application. Up until

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.