I have found the solution to this question while writing it, but I'm still posting it so that if somebody has this problem in the future, they can find this
This question is related to this question as in this is my latest attempt at solving my issue.
In short :
in my .Net MVC Project, I receive a Json with some unpredictable data (an array of :). I can decode this Json using
dynamic dynamicObj =System.Web.Helpers.Json.Decode(await someAPIcall(someParameters));
And i can explore the data by mousing over it in VisualStudio (although it is a much more complex structure as the json that is sent) and also the ObjectDumper nuget is able to display all the properties.
Now, how can i access this data in my code ?
I've tried the following :
Acessing the properties as with any object by chaining property names like :
dynamicObj._values[1].Key
which, following the path in the mouse over data explorer (don't know the name of it), should give me a simple string. But I get this error :
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform
runtime binding on a null reference
So I tried to see if maybe the name was somehow different in this object, so i tried :
foreach (string name in dynamicObj.getDynamicMemberNames())
{
Debug.WriteLine(name);
}
Which is a method of the DynamicJsonObject but this raises this error :
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform
runtime binding on a null reference
when clearly dynamicObj is not null.
What am I missing ?