I have this JSON
[{"usr_pres.name":"xxx","emp":"001"}]
which returns an ajax function.
I've always accessed each element like this:
success: function (data) {
objJsonPT = JSON.parse(data);
console.log(objJsonPT['0'].emp);
If I access the value of emp
, it returns it fine but if I access the value of usr_pres.name it gives me an error, it says that name is not defined. I think it has to do with the"."
However, when I do a console.log(data)
yes, I see the data well as I show it.
[{"usr_pres.name":"xxx","emp":"001"}]
What I would like would be to be able to access the value usr_pres.name
that would be: "xxx"
Thank you
Do it by using square brackets:
This is the correct way to access the JSON value whose name includes a period.
All the best!