At a Rest-API I got an incoming object from Type System.Object.
public async Task<IActionResult> UploadFileRegistration([FromBody]object incomingObject)
This object I would like to parse into my type.
public class MyType
{
public string name;
public double age;
}
The incoming object can has one more attribute "version" and the content of version can look different each time.
{"name":"Gisela", "age":29.64}
{"name":"Gisela", "age":29.64, "version":"new"}
{"name":"Gisela", "age":29.64, "version":2.0}
{"name":"Gisela", "age":29.64, "version":["param1":17,"param2":"oho"]}
{"name":"Gisela", "age":29.64, "version":true}
In case this object has a child with name "version". I want to remove this child and put it into a string. In the parent object the child should be removed.
How to do this?
I think of some thing what do's that (made-up code)..
private object o;
private string myVersion; //...
if(o.HasChild("version"))
{
myVersion = o.Child("version");
o.DeleteChild("version");
}