This should work...

JavaScriptSerializer ser = new JavaScriptSerializer();
var records = new ser.Deserialize<List<Record>>(jsonData);

public class Person
{
    public string Name;
    public int Age;
    public string Location;
}
public class Record
{
    public Person record;
}
Answer from I4V on Stack Overflow
🌐
Quora
quora.com › How-do-you-deserialize-JSON-in-the-C-language-on-Windows
How to deserialize JSON in the C language on Windows - Quora
Answer: You can use the cJSON library or any of a large number of alternatives listed in the C section of JSON.org. cJSON is written to the c89 standard so it will happily compile in GCC, Visual Studio, MinGW and probably every common C compiler.
Discussions

Deserializing a JSON array string into a C# object
A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories. ... If your array continues with X4,Y4,Z4, you have a problem since, for deserializing the strong type class from the JSON, the array entries should be known. More on learn.microsoft.com
🌐 learn.microsoft.com
2
0
December 23, 2021
C# deserialize JSON array - Unity Engine - Unity Discussions
I have been fighting this one for a bit now, can’t get the type casting right. I can deserialize a single JSON line but when I try to do an array, I’m running into problems. I have tried both the JSONFX code from here: https://bitbucket.org/darktable/jsonfx-for-unity3d/downloads as well ... More on discussions.unity.com
🌐 discussions.unity.com
0
December 29, 2011
JSON Array deserialization
Select an image from your device to upload · Please welcome our newest member Salma raja More on c-sharpcorner.com
🌐 c-sharpcorner.com
12
October 9, 2018
How to Deserialize JSON array(or list) in C# - Stack Overflow
Connect and share knowledge within a single location that is structured and easy to search. Learn more about Teams ... public static string DeserializeNames() { // Json I am passing for the deserialization. More on stackoverflow.com
🌐 stackoverflow.com
May 21, 2021
🌐
Zltl
zltl.github.io › json-gen-c
json-gen-c: json-gen-c
July 19, 2021 - Batteries included – includes a lightweight sstr string helper library and ready-made array helpers. CI-friendly build – warnings are treated as errors and the Make targets work the same locally and in automation. ... json-gen-c is a program for serializing C structs to JSON and deserializing JSON to C structs.
Top answer
1 of 2
2

If your array continues with X4,Y4,Z4, you have a problem since, for deserializing the strong type class from the JSON, the array entries should be known. To deserialize the current JSON, use the following classes:

public class Rootobject
{
    public Class1[] Property1 { get; set; }
}

public class Class1
{
    public string X1 { get; set; }
    public string Y1 { get; set; }
    public string Z1 { get; set; }
    public string X2 { get; set; }
    public string Y2 { get; set; }
    public string Z2 { get; set; }
    public string X3 { get; set; }
    public string Y3 { get; set; }
    public string Z3 { get; set; }
}

You may read the JSON dynamically instead of deserializing the array:

    using System.Text.Json.Nodes;
    var jsonString = "[{\"X1\":\"x1\",\"Y1\":\"y1\",\"Z1\":\"z1\"},{\"X2\":\"x2\",\"Y2\":\"y2\",\"Z2\":\"z2\"},{\"X3\":\"x3\",\"Y3\":\"y3\",\"Z3\":\"z3\"}]";
    var jsonObject = JsonNode.Parse(jsonString);
    Console.WriteLine(jsonObject.ToString());
    Console.WriteLine(jsonObject[0]["X1"]);

Alon.

2 of 2
0

Hi @Julio Bello ,

[{"X1":"x1","Y1":"y1","Z1":"z1"},{"X2":"x2","Y2":"y2","Z2":"z2"},{"X3":"x3","Y3":"y3","Z3":"z3"},...]

From the above JSON string, we can see that each property (key-value pair, such as "X1":"x1", "X2":"x2") has a different property name or key value, in this scenario the property is not fixed so we can directly use it as the class's property.

So, for the above JSON string, I suggest you could deserialize it uses a Dictionary, you can refer to the following sample code:

       //required using System.Text.Json;  

        var values = new List>()  
        {  
              new Dictionary()  
                {  
                    {"X1", "x1"},{"Y1", "Y1"},{"Z1", "Z1"}  
                },  
                  new Dictionary()  
                {  
                    {"X2", "x2"},{"Y2", "Y2"},{"Z2", "Z2"}  
                }  
        };   
        var jsonstring = JsonSerializer.Serialize(values);  
        //jsonstring: [{"X1":"x1","Y1":"Y1","Z1":"Z1"},{"X2":"x2","Y2":"Y2","Z2":"Z2"}]  
        var reult1 = JsonSerializer.Deserialize>>(jsonstring);  

        var test = new TestModel()  
        {  
            Item = new List>()  
            {  
                new Dictionary()  
                {  
                    {"X1", "x1"},{"Y1", "Y1"},{"Z1", "Z1"}  
                },  
                  new Dictionary()  
                {  
                    {"X2", "x2"},{"Y2", "Y2"},{"Z2", "Z2"}  
                }  
            }  
        };  

        var jsonstring2 = JsonSerializer.Serialize(test);  
        //josnstring2: {"Item":[{"X1":"x1","Y1":"Y1","Z1":"Z1"},{"X2":"x2","Y2":"Y2","Z2":"Z2"}]}  

        var result2 = JsonSerializer.Deserialize(jsonstring2);  

The TestModel

public class TestModel  
{  
    public List> Item { get; set; }  
}  

The output is like this:

And this sample code:

        var jsonstr = "[{\"X1\":\"x1\",\"Y1\":\"Y1\",\"Z1\":\"Z1\"},{\"X2\":\"x2\",\"Y2\":\"Y2\",\"Z2\":\"Z2\"}]";  

        var result3 = JsonSerializer.Deserialize>>(jsonstr);  

The result:

After that you can find the data from the Dictionary. More detailed information about Dictionary, see Dictionary Class


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best regards,
Dillion

🌐
Medium
medium.com › @zgza778 › deserialize-json-into-c-objects-the-right-way-09d173c7e8ad
Deserialize JSON into C Objects: The Right Way | by Phoebe Theresa Peters | Medium
January 3, 2025 - When dealing with nested objects or arrays within your JSON data, you might encounter challenges during deserialization. Newtonsoft.Json provides tools to address this. By carefully crafting your C classes to mirror the JSON structure, and utilizing features such as attributes to manage property mappings, you can efficiently handle complex data. For example, understanding how to correctly map JSON arrays to C lists is crucial. Consider using custom converters for particularly intricate structures or non-standard JSON formats.
🌐
Unity
discussions.unity.com › unity engine
C# deserialize JSON array - Unity Engine - Unity Discussions
December 29, 2011 - I have been fighting this one for a bit now, can’t get the type casting right. I can deserialize a single JSON line but when I try to do an array, I’m running into problems. I have tried both the JSONFX code from here: https://bitbucket.org/darktable/jsonfx-for-unity3d/downloads as well as the MiniJSON script from here: https://raw.github.com/gist/1411710/MiniJSON.cs Here’s my test code using System; using System.Text; using System.Reflection; using System.Collections; using System.Collections...
🌐
C# Corner
c-sharpcorner.com › home › forums › visual basic .net › json array deserialization
JSON Array deserialization
October 9, 2018 - var empObj = JsonConvert.DeserializeObject<List<Employee>>(json1); ... Please help. ... Please welcome our newest member Salma raja. 3,104,442 users have contributed to 147,365 threads and 483,820 · In the past 24 hours, we have 4 new threads, 14 new posts, and 60 new users.
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 49810503 › how-to-deserialize-json-arrayor-list-in-c-sharp
How to Deserialize JSON array(or list) in C# - Stack Overflow
May 21, 2021 - public class Head { public IList<List<Dictionary<string, object>>> TestRows{ get; set; } } public class Cookie { public Head Head { get; set; } } var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; var path= Path.Combine(baseDirectory, "test.json"); //deserialize JSON from file string JsonStream = System.IO.File.ReadAllText(path, Encoding.Default); var DeserializedCookieList = JsonConvert.DeserializeObject<Cookie>(JsonStream);
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › standard › serialization › system-text-json › deserialization
How to deserialize JSON in C# - .NET | Microsoft Learn
To deserialize from UTF-8, call a JsonSerializer.Deserialize overload that takes a ReadOnlySpan<byte> or a Utf8JsonReader, as shown in the following examples. The examples assume the JSON is in a byte array named jsonUtf8Bytes.
🌐
Stack Overflow
stackoverflow.com › questions › 31530897 › how-to-deserialize-a-json-array-in-c-sharp
How to Deserialize a JSON array in C# - Stack Overflow
Otherwise, if you really want some isolated elements only, you need to use the lower level parts of the JSON library: Parse the stream of tokens yourself, keep track of the object tree and return just the elements you need. ... Ty @DrKoch. But, That's the requirement given to me.. They need 2 seperate objects each containing the two different data(explained earlier) and to return those 2 objects by binding those into one single object. Can you give some examples on that...
🌐
Newtonsoft
newtonsoft.com › json › help › html › DeserializeCollection.htm
Deserialize a Collection
string json = @"['Starcraft','Halo','Legend of Zelda']"; List<string> videogames = JsonConvert.DeserializeObject<List<string>>(json); Console.WriteLine(string.Join(", ", videogames.ToArray())); // Starcraft, Halo, Legend of Zelda
🌐
Unity
discussions.unity.com › unity engine
Deserializing Json Array that contains arrays, to object array. - Unity Engine - Unity Discussions
June 20, 2022 - Hi there. I’ve been reading everything I found about raw JSON deserializing to objects, but I’m to newbee to face this JSON structure: I understand how to load my Items to an array of ClimatPoly[ ] type, but I don’t kn…
🌐
C# Corner
c-sharpcorner.com › forums › deserialize-json-array-object
Deserialize Json array object
October 26, 2024 - internal class Program { static void Main(string[] args) { string jsonString = @"[ { ""userid"": ""0001"", ""name"": ""Jake1"", ""transfers"": [ { ""recordsnumber"": ""5001"" }, { ""recordsname"": ""test"" }, { ""tmpbox"": ""5005"" }, { ""ddate"": ""10/23/2024"" }, { ""fromdate"": ""10/23/2024"" }, { ""todate"": ""10/23/2024"" }, { ""range"": ""5004"" } ] }, { ""userid"": ""0002"", ""name"": ""Jake2"", ""transfers"": [ { ""recordsnumber"": ""5001"" }, { ""recordsname"": ""test"" }, { ""tmpbox"": ""5005"" }, { ""ddate"": ""10/23/2024"" }, { ""fromdate"": ""10/23/2024"" }, { ""todate"": ""10/23/
Top answer
1 of 6
1
Hi shravan, Use this processor 1) Make Class Use in Property Get and set. namespace FormAssts { public class LoginModule { // [JsonProperty("Status")] public statuscode statusC { get; set; } public substatus Sub { get; set; } public discription dis{ get; set; } } } then this code for Deserialize var json = JsonConvert.DeserializeObject (strCheck);
2 of 6
1
Hi try this code string jsonstr="{ \"Status\": { \"StatusCode\":\"143\", \"SubStatus\":\"0\", \"Description\":\"Ok\" }, \"ListofCredDetails\": [{ \"Client\":\"a\", \"CredID\":111, \"CredUserID\":\"abc\" },{ \"Client\":\"b\", \"CredID\":112, \"CredUserID\":\"def\" },{ \"Client\":\"c\", \"CredID\":113, \"CredUserID\":\"ghi\" }] }\""; JObject jsonDes = JObject.Parse(jsonstr); string statuscode = jsonDes["Status"]["StatusCode"].ToString(); string SubStatus = jsonDes["Status"]["SubStatus"].ToString(); string Description = jsonDes["Status"]["Description"].ToString(); string Client1 = jsonDes["ListofCredDetails"].ElementAt(0)["Client"].ToString(); string CredID1 = jsonDes["ListofCredDetails"].ElementAt(0)["CredID"].ToString(); string CredUserID1 = jsonDes["ListofCredDetails"].ElementAt(0)["CredUserID"].ToString(); string Client2 = jsonDes["ListofCredDetails"].ElementAt(1)["Client"].ToString(); string CredID2 = jsonDes["ListofCredDetails"].ElementAt(1)["CredID"].ToString(); string CredUserID2 = jsonDes["ListofCredDetails"].ElementAt(1)["CredUserID"].ToString(); string Client3 = jsonDes["ListofCredDetails"].ElementAt(2)["Client"].ToString(); string CredID3 = jsonDes["ListofCredDetails"].ElementAt(2)["CredID"].ToString(); string CredUserID3 = jsonDes["ListofCredDetails"].ElementAt(1)["CredUserID"].ToString();
🌐
MojoAuth
mojoauth.com › serialize-and-deserialize › serialize-and-deserialize-json-with-c
Serialize and Deserialize JSON with C | Serialize & Deserialize Data Across Languages
November 19, 2025 - This guide shows you how to efficiently serialize C data structures into JSON strings and deserialize JSON back into C objects. You'll learn practical techniques to integrate JSON processing seamlessly into your C applications, saving you development time and reducing bugs.
🌐
.NET Fiddle
dotnetfiddle.net › eqJXTy
C# - Deserialize Json Arrays | C# Online Compiler | .NET Fiddle
March 30, 2025 - C# - Deserialize Json Arrays | Test your C# code online with .NET Fiddle code editor.
🌐
Reddit
reddit.com › r/dotnet › can i deserialize json object fields to an array of those fields
r/dotnet on Reddit: Can I deserialize json object fields to an array of those fields
December 19, 2022 -

Hi, I have what I think is just a case of bad API design that I have to deal with.

So What I get returned from the api, is a json object with x fields in them, being names of providers of articles. It looks like this:

{
"status": "ok", 
"result": { 
     "firstprovider": [ .... ],
      "secondprovider": [ ...], 
      "thirdprovider": [ ... ] 
  }
 }

In this example, only three provider are returned, but I could get more or less than that, and their names may vary. It's quite important that I save those names.

Each of the providers are objects, which are always formed in the same manner.

But, I would like to store the provider objects in a list of providers List<Provider>, where the name of the provider is included as a field in the Provider object.

How would one do that? It seems to me that "result" should actually have been an array for me to do this properly, but is there any way that I can get around this, and do what I am descirbing?

🌐
Coding Militia
blog.codingmilitia.com › posts › array or object json deserialization (feat. .net & system.text.json)
Array or object JSON deserialization (feat. .NET & System.Text.Json) | Coding Militia
January 31, 2022 - We’re inheriting from JsonConverter<IReadOnlyCollection<T>>, to implement the JSON converter for that specific type (I normally use IReadOnlyCollection when passing collections around instead of IEnumerable, to be sure the collection isn’t lazy unless I really want it to be). As for the read implementation, we check what the first token of the object’s JSON representation is: Array start token ([) - we deserialize it as an array