Could someone please provide guidance on the proper format for a Json? I am new to working with Json and Serialization.
I need to generate a Json from .Net in this specific format:
[[Date.UTC(2011,12,14,8), 8], [Date.UTC(2011,12,14,9), 1]]
I am close to achieving this but struggling with the formatting of my string, as it is automatically enclosed in quotes. Here is my current code snippet:
Dim oSerializerDt As New JavaScriptSerializer()
Dim dt As New DataTable
dt.Columns.Add("Date", GetType(String))
dt.Columns.Add("Count", GetType(Integer))
objresults.GetResults(id, period)
Dim listResults As New List(Of Object())
Dim newDate As String
For Each result As Application.NewResults In objresults
newDate = "Date.UTC(" + result.EventDate.Year.ToString + "," + result.EventDate.Month.ToString + "," + result.EventDate.Day.ToString + "," + result.EventDate.Hour.ToString + ")"
listResults.Add({newDate, result.Count})
Next
Return oSerializerDt.Serialize(listResults)
The generated Json looks like this, with double quotes around the time string:
[["Date.UTC(2011,12,14,8)",8],["Date.UTC(2011,12,14,9)",11]]
I would greatly appreciate any advice on how to modify my code to ensure the strings are correctly formatted. Thank you!
Best regards.