locked
Deserialize JSON Data in c# RRS feed

  • Question

  • { "universities":
    {"76":
    {"name":"Keiser University",
    "school":"Miami",
    "logo":"\/images\/content\/schools-big\/logo_keiser.gif",
    "programs":
    [
    {
    "id":"27463",
    "name":"Associate of Arts in Accounting",
    "school":"Miami",
    "degree":"Associate",
    "online":"0",
    "school_id":"883"
    },
    {
    "id":"27465",
    "name":"Associate of Arts in Business Administration",
    "school":"Miami",
    "degree":"Associate",
    "online":"0",
    "school_id":"883"
    },
    {"id":"27464","name":"Bachelor of Arts in Accounting","school":"Miami","degree":"Bachelor","online":"0","school_id":"883"},
    {"id":"1534075","name":"Bachelor of Arts in Business Administration with a concentration in Finance","school":"Miami","degree":"Bachelor","online":"0","school_id":"883"},
    {"id":"1534077","name":"Bachelor of Arts in Business Administration with a concentration in Human Resource Management","school":"Miami","degree":"Bachelor","online":"0","school_id":"883"},
    {"id":"1534074","name":"Bachelor of Arts in Business Administration with a concentration in Management","school":"Miami","degree":"Bachelor","online":"0","school_id":"883"},
    {"id":"1534076","name":"Bachelor of Arts in Business Administration with a concentration in Marketing","school":"Miami","degree":"Bachelor","online":"0","school_id":"883"},
    {"id":"1534073","name":"Bachelor of Arts in Business Administration with a concentration in International Business","school":"Miami","degree":"Bachelor","online":"0","school_id":"883"},
    {"id":"27466","name":"Bachelor of Arts in Business Administration","school":"Miami","degree":"Bachelor","online":"0","school_id":"883"},
    {"id":"1546952","name":"Bachelor of Arts in Psychology - Business Concentration","school":"Miami","degree":"Bachelor","online":"0","school_id":"883"}
    ],

    "description":"For over 30 years, Keiser University has maintained a practical, hands-on approach to career education to help our students achieve their personal and professional goals. Our student-centered approach remains at the foundation of the Keiser University mission and continues to attract students who prefer a more personal learning experience. \r\n\r\nAt Keiser University, you will find a warm, friendly community with faculty and staff truly committed to your success. Our small class sizes, individualized attention, and one-class-at-a-time schedules create a positive learning environment where you can excel. Whether your goal is to prepare for a new career or to advance with your current employer, Keiser University is designed around your needs. ",

    "additional_questions":
    [
    {
    "type":"checkbox",
    "name":"TCPAConsent",
    "label":"By checking this box, I consent to receive phone calls and\/or text messages from Keiser University at the phone number(s) provided, including a wireless number, using automated technology. Checking this box is required for us to contact you, without obligation to attend our University.",
    "options":"{\"label\": \"TCPA\",\"value\": \"yes\"}"
    }
    ]
      }
     },
      "interest_id":5089989
    }

    I want to deserialize the above json without mvc in c#. I have tried all the method but failed. Please someone help 

    Thank in Advance  

    Pravash

    • Moved by 宝宝徐 Friday, October 20, 2017 1:59 AM
    Tuesday, October 10, 2017 1:20 PM

All replies

  • Hi Pravash,

    Just found this tool for you.

    Please let me know if it helps.

     

    Best regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Wednesday, October 11, 2017 2:29 AM
    • Proposed as answer by Fletch Zhou Thursday, October 19, 2017 6:48 AM
    Wednesday, October 11, 2017 2:29 AM
  • If by “not using mvc” you do not mean “not using .NET”, then add a reference to System.Web.Extension, and try this code:

    string text = the JSON text. . .;

    var ser = new System.Web.Script.Serialization.JavaScriptSerializer();

    var dict = ser.Deserialize<dynamic>( text );

    var universities = dict["universities"];

    var university = universities["76"];

    string name = university["name"];

    string description = university["description"];

    . . .

    It is also possible to define a set of classes (see the “Paste JSON as Classes” feature of Visual Studio).

    • Proposed as answer by Fletch Zhou Thursday, October 12, 2017 6:56 AM
    Wednesday, October 11, 2017 5:23 AM