This project is read-only.
1

Closed

System.InvalidProgramException

description

I receive an System.InvalidProgramException, when i try to serialize an IEnumerable<DataRow> object.

StackTrace:
at _(Object )
at fastJSON.JSONSerializer.WriteObject(Object obj)
at fastJSON.JSONSerializer.WriteValue(Object obj)
at fastJSON.JSONSerializer.WriteArray(IEnumerable array)
at fastJSON.JSONSerializer.WriteValue(Object obj)
at fastJSON.JSONSerializer.ConvertToJSON(Object obj)
at fastJSON.JSON.ToJSON(Object obj, JSONParameters param)

Code to reproduce:
    dt = <DataTable>.AsEnumerable();
    if (0 < pageSize)
    {
        pageNum = 1 > pageNum ? 1 : pageNum;
        dt = dt
            .Skip((pageNum - 1) * pageSize)
            .Take(pageSize);
    }
    return new {
        ItemCount = itemList.Count,
        ResultSet = JSON.ToJSON(dt, new JSONParameters {
            SerializeNullValues = true,
            EnableAnonymousTypes = true
        })
    };
Workaround:
call dt.CopyToDataTable() before calling ToJSON
Closed Jul 15, 2016 at 3:20 PM by MGholam
Fixed in 2.1.17

comments