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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:43:28+00:00 2026-06-07T15:43:28+00:00

I am writing a deserializer callback method to parse some Json response in C#

  • 0

I am writing a deserializer callback method to parse some Json response in C# silverlight.

But the problem is the response is constructed by a bunch of objects and not in an array form.

To be specific, normally when we want to parse something from a json, if that’s a list of object, it will look like this in some Json visualizer:

Json Array

we can do something like:

DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(ObjType[]));
ObjType[] response = (ObjType[])jsonSerializer.ReadObject(stream);

But now I have the Json file that the structure looks like this:

enter image description here

In this case I dont think I can parse it to an array since the objects are individual and not in an array structure.

A sample of the Json file is:

[
   {
      "Name":"Mike",
      "Gender":"male",
   },
   {
      "Name":"Lucy",
      "Gender":"Female ",
   },
   {
      "Name":"Jack",
      "Gender":"Male",
   }
]

So I am wondering if there is any way I can parse this kind of Json file to an array of defined object.

  • 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-07T15:43:32+00:00Added an answer on June 7, 2026 at 3:43 pm

    This works for me

    string json = @"[
        {
            ""Name"":""Mike"",
            ""Gender"":""male""
        },
        {
            ""Name"":""Lucy"",
            ""Gender"":""Female ""
        },
        {
            ""Name"":""Jack"",
            ""Gender"":""Male""
        }
    ]";
    MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(json));
    
    DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(ObjType[]));
    ObjType[] response = (ObjType[])jsonSerializer.ReadObject(stream);
    

    –

    [DataContract]
    public class ObjType
    {
        [DataMember]
        public string Name;
        [DataMember]
        public string Gender;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an extension method for parsing JSON string for any given type.
I have a bunch of xml serialized objects in a database. But, I refactored
I'm writing a json deserializer for a phone object. One of the properties is
I'm writing a custom json deserializer and I'm writing this: public class MyObjectToJson :
I am writing a deserializer method, which looks like so: public <T> T deserialize(Object[]
I'm writing a custom deserializer that will deserialize a list by deserializing each of
Writing documentation in html requires some code examples. What to do with characters that
I'm writing a TCP chat server ( programming language does not mather ). It's
With some frequency I find myself writing APIs that offer an Iterator<Foo> which is
I'm writing some unit tests and I need to be able to Assert whether

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.