just take the string and use the JavaScriptSerializer to deserialize it into a native object. For example, having this json:

string json = "[{Name:'John Simith',Age:35},{Name:'Pablo Perez',Age:34}]"; 

You'd need to create a C# class called, for example, Person defined as so:

public class Person
{
 public int Age {get;set;}
 public string Name {get;set;}
}

You can now deserialize the JSON string into an array of Person by doing:

JavaScriptSerializer js = new JavaScriptSerializer();
Person [] persons =  js.Deserialize<Person[]>(json);

Here's a link to JavaScriptSerializer documentation.

Note: my code above was not tested but that's the idea Tested it. Unless you are doing something "exotic", you should be fine using the JavascriptSerializer.

Answer from Icarus on Stack Overflow
Top answer
1 of 5
70

just take the string and use the JavaScriptSerializer to deserialize it into a native object. For example, having this json:

string json = "[{Name:'John Simith',Age:35},{Name:'Pablo Perez',Age:34}]"; 

You'd need to create a C# class called, for example, Person defined as so:

public class Person
{
 public int Age {get;set;}
 public string Name {get;set;}
}

You can now deserialize the JSON string into an array of Person by doing:

JavaScriptSerializer js = new JavaScriptSerializer();
Person [] persons =  js.Deserialize<Person[]>(json);

Here's a link to JavaScriptSerializer documentation.

Note: my code above was not tested but that's the idea Tested it. Unless you are doing something "exotic", you should be fine using the JavascriptSerializer.

2 of 5
11
using Newtonsoft.Json;

Install this class in package console This class works fine in all .NET Versions, for example in my project: I have DNX 4.5.1 and DNX CORE 5.0 and everything works.

Firstly before JSON deserialization, you need to declare a class to read normally and store some data somewhere This is my class:

public class ToDoItem
{
    public string text { get; set; }
    public string complete { get; set; }
    public string delete { get; set; }
    public string username { get; set; }
    public string user_password { get; set; }
    public string eventID { get; set; }
}

In HttpContent section where you requesting data by GET request for example:

HttpContent content = response.Content;
string mycontent = await content.ReadAsStringAsync();
//deserialization in items
ToDoItem[] items = JsonConvert.DeserializeObject<ToDoItem[]>(mycontent);
Discussions

c# - How to Convert JSON object to Array - Stack Overflow
Sign up to request clarification or add additional context in comments. ... Save this answer. ... Show activity on this post. You are going to have to deserialize the Json String. Deserialize into array of objects. More on stackoverflow.com
🌐 stackoverflow.com
June 19, 2019
JSON Object to Array Conversion | OutSystems
I am receiving both Json object and json array from API, I need to convert those JSON object to Json array, Like Mentioned below · How to achieve this More on outsystems.com
🌐 outsystems.com
October 28, 2024
How to Convert Json Object to Array in C# - Stack Overflow
I am trying to convert a JSON object in to C# array. More on stackoverflow.com
🌐 stackoverflow.com
July 4, 2015
How to convert JSON object to JavaScript array? - Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... I need to convert JSON object string to a JavaScript array. More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
gist.github.com › alan-mushi › 19546a0e2c6bd4e059fd
Examples for the json-c tutorial. · GitHub
Sorry but I don't understand. Where is your system? Where can I find that? Can u send me a link? ... you just have to install libjson-c in your system.
🌐
OutSystems
outsystems.com › forums › discussion › 99971 › json-object-to-array-conversion
JSON Object to Array Conversion | OutSystems
October 28, 2024 - I am receiving both Json object and json array from API, I need to convert those JSON object to Json array, Like Mentioned below · How to achieve this
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-convert-json-string-to-array-of-json-objects-using-javascript
Convert JSON String to Array of JSON Objects in JavaScript | GeeksforGeeks
December 4, 2024 - The below approaches can be utilized to JSON stringify an array of objects.Table of ContentUsing JSON.stringify with a Replacer Function Using a C ... A map in JavaScript is a set of unique key and value pairs that can hold multiple values with only a single occurrence. Sometimes, you may be required to convert a map into an array of objects that contains the key-value pairs of the map as the values of the object keys.
Find elsewhere
🌐
Json-c
json-c.github.io › json-c › json-c-0.10 › doc › html › json__object_8h.html
json-c: json_object.h File Reference
See also json_type_to_name() to turn this into a string suitable, for instance, for logging. ... type being one of: json_type_null (i.e. obj == NULL), json_type_boolean, json_type_double, json_type_int, json_type_object, json_type_array, json_type_string, ... Create a new empty json_object of type json_type_int Note that values are stored as 64-bit values internally.
🌐
JD Bots
jd-bots.com › 2021 › 10 › 17 › how-to-convert-json-array-to-json-object-in-net-c
How to Convert JSON Array to JSON Object in .NET C#? - JD Bots
October 17, 2021 - In some cases, there will be only a single JSON object returned from the API response. The code we will write will handle any scenario having 1 object or multiple objects. For demo purposes, I am hardcoding the JSON array in a string variable.
🌐
Webdevtutor
webdevtutor.net › blog › c-sharp-convert-json-object-to-array
How to Convert JSON Object to Array in C#
One of the popular libraries for handling JSON in C# is Newtonsoft.Json. You can use this library to deserialize a JSON object into an array.
🌐
Programming in Linux
linuxprograms.wordpress.com › category › json-c
json-c – Programming in Linux
Specify the object where the json object has to be added, key and the value (json object) as the arguments · The following program shows the usage of the function · #include <json/json.h> #include <stdio.h> int main() { /*Creating a json object*/ json_object * jobj = json_object_new_object(); /*Creating a json array*/ json_object *jarray = json_object_new_array(); /*Creating json strings*/ json_object *jstring1 = json_object_new_string("c"); json_object *jstring2 = json_object_new_string("c++"); json_object *jstring3 = json_object_new_string("php"); /*Adding the above created json strings to
🌐
SitePoint
sitepoint.com › blog › javascript › jquery convert json string to array
jquery convert json string to array — SitePoint
February 12, 2024 - Here is an example: $json_str = '{"name":"John", "age":30, "city":"New York"}'; $obj = json_decode($json_str, true); echo $obj['name']; In this example, json_decode() function converts the JSON string into a PHP array, which you can then access like any other PHP array.
🌐
Reddit
reddit.com › r/microsoftflow › need help converting a json object to an array
r/MicrosoftFlow on Reddit: Need help converting a JSON object to an array
March 25, 2026 -

Hi all.

I'm trying to set up an automation flow at work, but I've ran into an issue. My flow is fetching data from a SOAP API (an API I do not control), which is returning a JSON object. I need to somehow convert this JSON object into an array, so I can iterate over it in the rest of my flow.

I can't seem to find a way to reliably do this and I'm getting quite mad. The API returns a SOAP envelope, with a return value, which is structured as follows:

{
  "id1":{ 
    "value1":string,
    "value2":string
  },
  "id2":{
    "value1":string,
    "value2":string
  },
  "id3":{
    "value1":string,
    "value2":string
  },
  etc...
}

I can convert the return string to a JSON object, but than I have a single object with a load of values I can't iterate over (or at least I don't know how).

Anyone have a good idea on how to solve this?

🌐
Tutorial Teacher
tutorialsteacher.com › articles › convert-json-string-to-object-in-csharp
Parse JSON string to Class Object in C#
Many times the JSON string contains an array to store multiple data. This can be converted to an array or list of objects in C#. The following example shows how to parse JSON array to C# list collection.
🌐
W3Schools
w3schools.com › js › js_json_stringify.asp
JavaScript JSON.stringify()
JSON.stringify() cannot convert objects that contain circular references.