I'm receiving a JSON string in a MVC4/.NET4 WebApi controller action. The action's parameter is dynamic
because I don't know anything on the receiving end about the JSON object I'm receiving.
public dynamic Post(dynamic myobject)
The JSON is automatically parsed and the resulting dynamic
object is a Newtonsoft.Json.Linq.JContainer
. I can, as expected, evaluate properties at runtime, so if the JSON contained something like myobject.myproperty then I can now take the dynamic object received and call myobject.myproperty
within the C# code. So far so good.
Now I want to iterate over all properties that were supplied as part of the JSON, including nested properties. However, if I do myobject.GetType().GetProperties()
it only returns properties of Newtonsoft.Json.Linq.JContainer
instead of the properties I'm looking for (that were part of the JSON).
Any idea how to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…