I am trying to loop through the object I received from jQuery AJAX method into my aspx.cs page.
My object structure (I get object[] of 5 objects)
![I get object[] of 5 objects](https://www.lemona.fr/i.sstatic.net/dtj8M.png)
I want to get the value of BusinessOwner (how to access these properties)

I am trying to loop through the object I received from jQuery AJAX method into my aspx.cs page.
My object structure (I get object[] of 5 objects)
![I get object[] of 5 objects](https://www.lemona.fr/i.sstatic.net/dtj8M.png)
I want to get the value of BusinessOwner (how to access these properties)

Maybe something like this might help?
using System;
using System.Dynamic;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public class Program
{
public static void Main()
{
IDictionary<string,object> rptBusDetails = new ExpandoObject();
rptBusDetails["rptBusDetails"] = new List<object>
{
new Dictionary<string, string>() {{"BusinessOwner", "Mark"}, {"ChartReq", ""}},
new Dictionary<string, string>() {{"BusinessOwner", "Tom"}, {"ChartReq", ""}}
};
var parent = new object[] { rptBusDetails };
foreach(var node in parent)
{
var details = JObject.FromObject(node);
foreach(var detail in details["rptBusDetails"])
{
string owner = detail["BusinessOwner"].Value<string>();
Console.WriteLine(owner);
}
}
}
}
[Updated]
JObject o = JObject.FromObject(object); newtonsoft.com/json/help/html/CreatingLINQtoJSON.htm?What have you tried? something as easy as this should work, based on your question.
List<string> businessOwners = new List<string>();
foreach (object[] objArray in rptBusDetails) {
foreach (object obj in objArray){
businessOwners.Add((JToken)obj["BusinessOwner"].ToString());
}
}
since you didn't say what you wanted to do with the BusinessOwner property, I put them in a list.