How to fetch value from the nested json array in angular?

Asked on December 22, 2017
Hello,
I want to fetch the value from the nested json array in angular2.
I want to fetch the client_id from the following json array:
{
"resources" : [ {
"scope" : [ "clients.read", "clients.write" ],
"client_id" : "tc53EZ",
"resource_ids" : [ "none" ],
"authorized_grant_types" : [ "client_credentials" ],
"redirect_uri" : [ "http://ant.path.wildcard/**/passback/*", "http://test1.com" ],
"autoapprove" : [ "true" ],
"authorities" : [ "clients.read", "clients.write" ],
"token_salt" : "C7NBIz",
"allowedproviders" : [ "uaa", "ldap", "my-saml-provider" ],
"name" : "My Client Name",
"lastModified" : 1512452520895
} ],
"startIndex" : 1,
"itemsPerPage" : 1,
"totalResults" : 1,
"schemas" : [ "http://cloudfoundry.org/schema/scim/oauth-clients-1.0" ]
}
Can anyone help me out.
Thanks & Regards
Shilpa Kulkarni

Replied on December 22, 2017
Create a method to access JSON data:
url = ".....";
getData(): Observable<any> {
return this.http.get(this.url).map(res => res.json());
}
Now fetch client id:
this.getData().subscribe(
res => {
let resources = res["resources"];
let resource = resources[0];
console.log(resource["client_id"]);
}
);

Replied on December 24, 2017
Thank you. This is worked.