I'm writing a WebApi that returns an object MyObject. The MyObject class is defined in another DLL which i cannot modify it's source. This MyObject class did not put setters/getters so the public members are not properties, they are just fields.
So in my WebApi code, i want to return this Json MyObject, but all i am getting in the http request is an empty {} json data, when i know for a fact the object does contain data. The only difference is it did not pub setters/getters, that why it is returning {} noting.
How can i return the MyObject back as Json with data without having to make my own MyOwnObject which all the exact fields but property set them as get/set properties?
For Example, if i use
public class MyObject
{
public string name;
}
this version returns empty {} data even if name contains something, where as
public class MyObject
{
public string name { get; set; }
}
will property return the Json data, but i am unable to modify MyObject because it is written from another DLL, which i dont have source.
Many thanks.