Serialize anonymous objects for upload resposne from server .NET
Serialize anonymous objects for upload resposne from server .NET
I am trying to create a server response from the upload files post from Editor. I am using https://editor.datatables.net/manual/server as the basis for the resposne.
C# does not let me have Variable as the Key -- the "1" object below. Is there a solution to this? Note it also cannot be a number, but this I can get around with an undersocre and bit of server side manipualtion.
C# server side example:
JsonConvert.SerializeObject(new { 1 = new { filename = "Screen Shot.png" ...} } )
The 1 cannot be a variable (the File Id as suggested in the example).
Any advise - hints to a solution?
{
"files": {
"files": {
** "1": **{
"filename": "Screen Shot.png",
"web_path": "\/upload\/1.png"
},
**"2": **{
"filename": "Screen .png",
"web_path": "\/uplo.png"
}
}
},
"upload": {
"id": "1",
"id": "2"
}
}
Answers
Got there using NewtonSoft: