Problem with Json value
Problem with Json value

I have a json like this, the problem is that when I put in column the field proy_sim.name or prsp_def.name I get an error. The other fields work well.
This is my Json
"prsp_sol": [
{
"proy_sim.name": "Vehículos",
"prsp_def.name": "TRACTOR",
"prsp_def": 2613,
"his_sim": 72
}
]
the colum:
"columns": [
{
{"data": "proy_sim.name"},
{"data": "prsp_def.name"},
{"data": "prsp_def"},
{"data": "his_dim"},
}
]
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @silens ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
"proy_sim.name"
indicates to Datatables that this is a nested object as shown in this example:https://datatables.net/examples/ajax/deep.html
Datatables will expect the data structure to look more like this:
Although that would result in a duplicate key as noted.
Instead of periods can you use another character like underscore, for example:
"proy_sim_name": "Vehículos",
?Also note that you have an extra set of
{}
in your columns.data:Kevin
Thank you very much for your response, I can not change the character, I am desperate already with this problem, would there be a way to fix it without changing the character?
Just looked at the
columns.data
docs and it states this:. - Dotted Javascript notation. Just as you use a . in Javascript to read from nested objects, so to can the options specified in data. For example: browser.version or browser.name. If your object parameter name contains a period, use \\ to escape it - i.e. first\\.name.
Sounds like your change should look like this:
Kevin