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

  • Home
  • SEARCH
  • 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 6979745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:55:30+00:00 2026-05-27T17:55:30+00:00

This is my first try to deserialize a JSON string returned by Facebook. I

  • 0

This is my first try to deserialize a JSON string returned by Facebook.
I want to make sure future developers can maintain my code comfortably so I would like to know if this is okay way to do it. I am concerned that if the JSON string change then I will need to rewrite some of my classes.
Is the JSON string returned from Facebook likely to change? For example if location became a different object I will need to make changes right?

using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Web;
//--- If you are not able to add reference dont worry. You probably need to install ASP.NET Ajax or target higher .NET Framework (3.5 or 4).
//---   There are Stack Overflow threads about this.
using System.Web.Script.Serialization;

//--- Our Facebook Person class.
public class FBPerson
{
    public string id { get; set; }
    public string email { get; set; }
    public string name { get; set; }
    public string gender { get; set; }
    public IDName location { get; set; }
    public List<FBObject> work { get; set; }
    public List<FBObject> education { get; set; }
}
//-- In some cases only id and name will be accessed
public class IDName
{
    public string id { get; set; }
    public string name { get; set; }
    public string type { get; set; }
}
//-- work and education presently are array of json strings
public class FBObject
{
    public IDName employer { get; set; }
    public IDName school { get; set; }
}
static class Program
{
    //-- Sample JSON string returned by Facebook
    const string json2 = @"{
        ""id"":""11111111111111111"",
        ""name"":""Tester Test"",
        ""first_name"":""Tester"",
        ""last_name"":""Test"",
        ""link"":""http:\/\/www.facebook.com\/profile.php?id=11111111111111111"",
        ""location"":
            {""id"":""107991659233606"",""name"":""Atlanta, Georgia""},
        ""work"":
            [{""employer"":{""id"":""222222222222222222"",""name"":""Various""}}],
        ""education"":
            [
                {""school"":{""id"":""108000000000000"",""name"":""Test High School""},""type"":""High School""},
                {""school"":{""id"":""105000000000000"",""name"":""Tester College""},""type"":""College""}
            ],
        ""gender"":""male"",
        ""email"":""tester\u0040gmail.com"",
        ""timezone"":-5,""locale"":""en_US"",
        ""verified"":true,
        ""updated_time"":""2011-11-21T21:10:20+0000""
    }";

    static void Main()
    {
        JavaScriptSerializer ser = new JavaScriptSerializer();
        FBPerson fperson = ser.Deserialize<FBPerson>(json2);

        //-- Display the user info from the JSON string
        Console.WriteLine(fperson.id.ToString());
        Console.WriteLine(fperson.name.ToString());
        Console.WriteLine(fperson.gender.ToString());
        Console.WriteLine(fperson.email.ToString());
        Console.WriteLine(fperson.location.name.ToString());
        Console.WriteLine(fperson.work[0].employer.name.ToString());
        Console.WriteLine(fperson.education[0].school.name.ToString());
        Console.ReadLine();
    }
}
  • 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-05-27T17:55:31+00:00Added an answer on May 27, 2026 at 5:55 pm

    This seems fine. No matter how you do deserialization, changes to the JSON data format would break you. For that reason, API authors try very hard to avoid making such changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i try to deserialize a json string with the help of gson. While gson.fromJson
Technically this is my first try in nodejs and frankly I am not sure
This is my first try to work with databases in android.i want my app
First off - hello, this is my first Stack Overflow question so I'll try
I have a JSON data like this: { hello: { first:firstvalue, second:secondvalue }, hello2:
I've thrown a glance at Prolog, and this is my first little try at
I want to write an application to work with adress books. My first try
could not deserialize json into objects. try to use DataContractJsonSerializer . here is how
This is my first try trying to use WCF, so I'm guessing I'm doing
This first lines work, and i get V(i) =V+QIN(i)-QOUT(i), but when i try to

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.