I have an JSON Object like this:
public class RootObject
{
public string Number { get; set; }
public string ChannelType { get; set; }
public string ServiceName { get; set; }
public List<ImageInfos> ImageInfos { get; set; }
public bool IsInMixedFolder { get; set; }
public string Name { get; set; }
public string Id { get; set; }
public string DateCreated { get; set; }
public string DateModified { get; set; }
public string DateLastSaved { get; set; }
public List<object> LockedFields { get; set; }
public string ParentId { get; set; }
public List<string> Studios { get; set; }
public List<string> Genres { get; set; }
public ProviderIds ProviderIds { get; set; }
}
With ImageInfos like this:
public class ImageInfos
{
private string Path;
private string Type;
private string DateModified;
public ImageInfos(string Path, string Type, string DateModified)
{
this.Path = Path;
this.Type = Type;
this.DateModified = DateModified;
}
I am trying to fill the json ImageInfos-List with values and serialize it to a new string:
jsonObject = JsonConvert.DeserializeObject<RootObject>(json);
List<ImageInfos> newInfos = new List<ImageInfos>();
newInfos.Add(new ImageInfos("Test", "Test", "Test"));
jsonObject.ImageInfos = newInfos;
string newJSON = JsonConvert.SerializeObject(jsonObject);
But the new json looks like that:
"{\"Number\":\"35\",\"ChannelType\":\"TV\",\"ServiceName\":\"DVBLink\",\"ImageInfos\":[{}],\"IsInMixedFolder\":false,\"Name\":\"13th Street HD\",\"Id\":\"466ab1fb9be4f77e65ad2b229a15c326\",\"DateCreated\":\"2015-09-14T12:55:51.4081476Z\",\"DateModified\":\"0001-01-01T00:00:00.0000000Z\",\"DateLastSaved\":\"2015-10-17T13:34:37.4214116Z\",\"LockedFields\":[],\"ParentId\":\"00000000000000000000000000000000\",\"Studios\":[],\"Genres\":[],\"ProviderIds\":{\"ProviderExternalId\":\"13250000\"}}"
Why is ImageInfos empty in the new JSON string ?