I am using the C# API client (version 15.10.0) to query ScheduleEventService. That all works fine and I’m able to get the records I need. My problem is that I want to be able to serialize that data and save it locally in case of a network outage when my application is restarted. To accomplish this, I want to serialize the ScheduleEvent data to json using
Eventually I will want to serialize an entire list of ScheduleEvent objects, but I haven’t been able to get that far, so in the meantime I’m just serializing individual objects for testing purposes. This works except the json nodes end up matching the Pascal case of the class names. This appears to be a problem because the deserialization process is looking for camel case node names. Using the following lines generates empty objects.
dynamic jToken = JToken.Parse(json);
ScheduleEvent myDeserializedScheduleEvent = new ScheduleEvent(JToken.Parse(json));
I assume this is the correct way to deserialize the json data. I would prefer to use the following built-in deserialization process, but that doesn’t seem to work, either.
myDeserializedScheduleEvent = JsonConvert.DeserializeObject(json);
I get error message “Unable to find a constructor to use for type Kaltura.Enums.ScheduleEventRecurrenceFrequency.”
So, next I tried to modify the Kaltura client to specify camel case json node names in the JsonProperty attribute (example [JsonProperty(“startDate”)] on each of the properties of the ScheduleEvent class and its base class hierarchy. This seems to have worked for the most part, but I now get an error message at the ObjectFactory class, indicating “Cannot access child value on Newtonsoft.Json.Linq.JValue.”
Have I broken something by declaring the json property names to something different? If so, and if those need to be removed, how do I serialize the data so it can be deserialized later? Json seemed to be the preferred method based on the API client code.