Deserialize Json Object in Json Object RRS feed

  • Question

  • He Devs,

    I´m trying to DeSerialize a Json Object, wich even consists of another Json Object. I use the DataContractJsonSerializer to do this.

    My Json Object looks like this:

        "uuid": "1234",
        "water": {
          "shortname": "test123",
          "longname": "12312312"
        "timeseries": [
            "currentMeasurement": {just an arry like water...},

    The uuid and the array(water) could be set in my classes, but while trying to deserialze with the Json Object "timeseries"

    I am getting an Error from my  Datacontractor:

    "System.InvalidCastException: Unable to cast object of type 'System.Collections.Generic.List`1[System.Object]' to type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]'."

    That makes sence, becaus the class he try to Deserialze the object in looks like this:

      public class cStation
            public String uuid;
            public cTimeseries timeseries;
            public cWater water;

    And the timeseries =

        public class cTimeseries
            cMeasurement currentMeasurement;

    Now here ist my Question:

    How could i deserialize the whole object with the recursive Json object "timeseries". ?

    Thanks a lot!


    Wednesday, November 27, 2013 4:00 PM

All replies