Json to object[] RRS feed

  • Question

  • is it possible to convert json 



    object[] of type Datetime because I this code below to call stored procedures dynamically?

    object [] Params = (object [])JsonConvert.DeserializeObject(JSON, typeof (object []));
    Type currType = context.GetType();
    MethodInfo currMethod = currType.GetMethod(StoredProcedureName);
    var SPResults = currMethod.Invoke(context, Params);

    When it hits the invoke line, it fails giving me this: Object of type 'System.String' cannot be converted to type 'System.Nullable`1[System.DateTime]'.

    Any ideas on how to tackle this problem?


    Tuesday, January 5, 2010 6:17 PM


  • DateTime?[] dates = Params.Select(d => {
            DateTime dt;
            if(DateTime.TryParse(d, out dt))
                return dt;
        return (DateTime?)null;
    • Marked as answer by Bin-ze Zhao Friday, January 8, 2010 6:36 AM
    Wednesday, January 6, 2010 10:10 AM