0

enter image description here

Big Picture

i have this dynamic object. it is an array of object. i want to do a foreach loop in this object array.

i can foreach for a single object like below

 foreach (KeyValuePair<dynamic, dynamic> pair in jsonstaticobj1232)
            {
                dwt.Add(pair.Key, pair.Value);

            }

but how to foreach loop in a obj array?

3 Answers 3

1

foreach loop for dynamic object in array.

foreach (dynamic dObject in mArray)
{

}
Sign up to request clarification or add additional context in comments.

Comments

1

Try this

for(int=0;i<jsonstaticobj1232.Length;i++)
{

foreach (KeyValuePair<dynamic, dynamic> pair in jsonstaticobj1232[i])
        {
            dwt.Add(pair.Key, pair.Value);

        }
}

Comments

0
       List<string> layers = new List<string>();
       var dict = jss.Deserialize<Dictionary<string, dynamic>>(json);
                foreach (Dictionary<string,dynamic> key in dict["layers"])
                {
                    key.TryGetValue("name", out layersDic);
                    layers.Add(layersDic);
                }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.