79266027

Date: 2024-12-09 18:12:39
Score: 1
Natty:
Report link

Finally working on my side, with some other solutions, I found somethig that works. Here's the code help with another stack overflow.

            dynamic parsed = JsonConvert.DeserializeObject(MyJSON);
            var jObj = (JObject)parsed;

            foreach (JToken token in jObj.Children())
            {
                if (token is JProperty)
                {
                    var prop = token as JProperty;
                    Console.WriteLine("hello {0}={1}", prop.Name, prop.Value);
                }
            }

Find the solution with another stackoverflow here: dynamic JContainer (JSON.NET) & Iterate over properties at runtime

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: baronming