akash akash - 5 months ago 19
AngularJS Question

I want only string value from JSON.Stringify

alert(JSON.stringify(Attendances.data));


It gives this result:

[{"EmpNTLogin":"Gautam"}]


What I want:

"Gautam"

Answer

You don't need to stringify it.

alert(Attendances.data[0].EmpNTLogin);

Attendances.data is an array of JSON objects, that each have an EmpNTLogin property. Attendances.data[0] gets the first JSON object in the array, and .EmpNTLogin gets the value associated with the EmpNTLogin property, in this case "Guatam".