I have an array which I get from Database as below
var sampleArray =
{ID:1, ANALYSIS_NAME : "name1",
custodians:"[{\"ID\": 1, \"NAME\": \"abc\"},
{\"ID\": 2, \"NAME\": \"xyz\"},
{\"ID\": 3, \"NAME\": \"pqr\"}]"
};
How do I get name from the above array. I am able to display console.log(sampleArray.custodians) But When I tried to display console.log(sampleArray.custodians.name) I am getting an error Cannot read property 'NAME' of undefined.
return(<div>
<Panel>test</panel>
/*custodians should come here*/
</div>)
How to display the above object? please help. Thanks in advance
custodiansis JSON, so you first have to parse it ->JSON.parse()sampleArrayis not an array it's an object. Also,custodiansis stringified (serialized as text).