I'am trying to display a Json string and I have some douts if my string is correct...
This is what i've done so far:
//defining tehe string
var test = "{\"data\":[[100.50, 170.00, \"13/04/2022\", \"Vigente\", 14, 15]]}";
//return my string
return Json(test);
//NOTE -- I'am using C# controler to make this work
and this is what I have to follow --- Image that i trying to display like
I'am doing this right, if not whats is the right sintaxe to display that?
CodePudding user response:
DO NOT ATTEMPT TO MANUALLY CREATE JSON
You should never attempt to generate JSON yourself like this as it is prone to errors. Anyway, Json()
takes an object to serialize and will do it for you.
What you should do is:
var test = new {
data = new List<List<object>>{
new List<object>{ 100.50, 170.00, "13/04/2022", "Vigente", 14, 15 }
}
};
return Json(test);
Even better would be to create a ViewModel object that you can populate instead of using an anonymous type.