المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Deserialise complicated Jason data



C# Programming
08-15-2011, 03:41 PM
Dear all,

I have this jason data that ready to be serialised: (Indention added for readability)

{"Error":"", "UserMeasurements": [{ "MeasurementName":"BloodPressure", "ClinicalDatas": [{"Name":"Systolic", "Unit":"mmHg ", "ClinicalDataPoints":[[1304197968110,149],[1304290213920,145],[1304369712717,159],[1304459900650,160], [1304542964530,176],[1304564292340,147],[1304649916767,141],[1304726125653,139],[1304826583873,156], [1304880946500,167],[1305069333890,152]]}, {"Name":"Diastolic", "Unit":"mmHg ", "ClinicalDataPoints":[[1304197968220,129],[1304290215047,92],[1304369712763,91],[1304459900900,105], [1304542965530,83],[1304564292403,103],[1304649916797,81],[1304726125687,133],[1304826584000,85], [1304880946547,108],[1305069334890,89]]}, {"Name":"Mean Blood Pressure", "Unit":"mmHg ", "ClinicalDataPoints":[]} ] } ] }";
and I have these c# code to deserialised it:

namespace Json { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { **********Serializer js = new **********Serializer(); string test = "{\"Error\":\"\",\"UserMeasurements\":[{\"MeasurementName\":\"BloodPressure\",\"ClinicalDatas\":[{\"Name\":\"Systolic\",\"Unit\":\"mmHg \",\"ClinicalDataPoints\":[[1304197968110,149],[1304290213920,145],[1304369712717,159],[1304459900650,160],[1304542964530,176],[1304564292340,147],[1304649916767,141],[1304726125653,139],[1304826583873,156],[1304880946500,167],[1305069333890,152]]},{\"Name\":\"Diastolic\",\"Unit\":\"mmHg \",\"ClinicalDataPoints\":[[1304197968220,129],[1304290215047,92],[1304369712763,91],[1304459900900,105],[1304542965530,83],[1304564292403,103],[1304649916797,81],[1304726125687,133],[1304826584000,85],[1304880946547,108],[1305069334890,89]]},{\"Name\":\"Mean Blood Pressure\",\"Unit\":\"mmHg \",\"ClinicalDataPoints\":[]}]}]}"; Measurement result = js.Deserialize(test); } } public class Measurement { public string Error { get; set; } public List UserMeasurements { get; set; } } public class UserMeasurement { public string MeasurementName { get; set; } public List UserClinicalDatas { get; set; } } public class ClinicalDatas : List { public string Name { get; set; } public string Unit { get; set; } public string[][] ClinicalDataPoints { get; set; } } }
I am able to get the value for MeasurementName property, but the UserClinicalDatas always returns null, can someone in here point me out why this is the case? Many thanks.