Is there a way using NewtonSoft.Json or JavaScriptSerializer to serialize a DataTable as array of arrays instead of Array of objects. For example I need to serialize the datatable as below
[["Yellow", "Large", "Cotton"],["Red", "Medium", "Linen"]]
instead of
[{"Color":"Yellow", "Size":"Large", "Make":"Cotton"},{"Color":"Red", "Size":"Medium", "Make":"Linen"}]
尝试这个:
JsonConvert.SerializeObject(dataTable.AsEnumerable().Select(r => r.ItemArray));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.