I'm using JSON.NET to try and convert a type of Bar to JSON.
public class Foo {
String A;
String B;
Int32 C;
DateTime D;
}
public class Bar {
String E;
String F;
String G;
Foo H;
}
And I'm using this to convert a Bar to JSON.
public String ConvertBar(Bar _bar) {
String Result = JsonConvert.SerializeObject<Bar>(_bar);
return Result;
}
Something like this should be output:
{
"E": "Another Value",
"F": "Flamingos",
"G": "Another Another Value",
"H": [
{
"A": "Some Value",
"B": "Some Other Value",
"C": 42,
"D": "2000-01-013T00:00:00Z"
}
]
}
Whatever I do, the output of ConvertBar() is always null. So how are you supposed to convert Bar into JSON while retaining the values of Foo? I've heard you have to create a converter but I have no experience in those.
MessageJSONproperty