Parsing JSON is just slightly not right coming from .net Json serialzer
Parsing JSON is just slightly not right coming from .net Json serialzer
I have a specific serialization issue, and I hope someone can help
The resulting serialized objects are *slightly* incorrect, and not recognized by datatables as valid.
This is the JSON result
{ "aaData": [
{"engine":"das boot","browser":"das boot","platform":"das boot","version":"das boot","grade":"das boot"},
{"engine":"regulator","browser":"regulator","platform":"regulator","version":"regulator","grade":"regulator"}
]
}
But DataTables wants it like this:
{ "aaData": [
[das boot","das boot","das boot","das boot","das boot"],
["regulator","regulator","regulator","regulator","regulator"]
]
}
I know the issues. Two things are different. The property name is returning as - "engine":"das boot" instead of just "das boot"
But more annoying each row is wrapped in "{ }" instead if "[ ]".
Firebug thinks my Json results are prefect. but Datatables doesn't like it.
So this may be a .NET serialization question in the end.
I'm using MVC and VB.NET
My controller action
_
Function AjaxHandlerForBrowsers(param As JQueryDataTableParamModel) As ActionResult
Using Context As New TFEEntities
Dim daList = Context.JobTasks.Select(Function(job) New mything With {.engine = job.Notes, .browser = job.Notes, .platform = job.Notes, .version = job.Notes, .grade = job.Notes}).ToList
Dim wrapped = New With {.aaData = daList}
Return Json(wrapped, JsonRequestBehavior.AllowGet)
End Using
End Function
Any idea? Thanks for helping out.
The resulting serialized objects are *slightly* incorrect, and not recognized by datatables as valid.
This is the JSON result
{ "aaData": [
{"engine":"das boot","browser":"das boot","platform":"das boot","version":"das boot","grade":"das boot"},
{"engine":"regulator","browser":"regulator","platform":"regulator","version":"regulator","grade":"regulator"}
]
}
But DataTables wants it like this:
{ "aaData": [
[das boot","das boot","das boot","das boot","das boot"],
["regulator","regulator","regulator","regulator","regulator"]
]
}
I know the issues. Two things are different. The property name is returning as - "engine":"das boot" instead of just "das boot"
But more annoying each row is wrapped in "{ }" instead if "[ ]".
Firebug thinks my Json results are prefect. but Datatables doesn't like it.
So this may be a .NET serialization question in the end.
I'm using MVC and VB.NET
My controller action
_
Function AjaxHandlerForBrowsers(param As JQueryDataTableParamModel) As ActionResult
Using Context As New TFEEntities
Dim daList = Context.JobTasks.Select(Function(job) New mything With {.engine = job.Notes, .browser = job.Notes, .platform = job.Notes, .version = job.Notes, .grade = job.Notes}).ToList
Dim wrapped = New With {.aaData = daList}
Return Json(wrapped, JsonRequestBehavior.AllowGet)
End Using
End Function
Any idea? Thanks for helping out.
This discussion has been closed.
Replies
Allan