admin管理员组

文章数量:1399490

I want to get the value by the key of this json. The key is description and i want it in my console.log, i don't really get how to get this value, the filtering before worked fine.

{
    "id": "149",
    "description": "Try"
}

Thanks!

I want to get the value by the key of this json. The key is description and i want it in my console.log, i don't really get how to get this value, the filtering before worked fine.

{
    "id": "149",
    "description": "Try"
}

Thanks!

Share Improve this question edited Feb 1, 2018 at 12:00 Suren Srapyan 68.7k14 gold badges125 silver badges117 bronze badges asked Feb 1, 2018 at 11:59 muellestemuelleste 411 gold badge1 silver badge3 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

First You need to parse it using JSON.parse. Then using . or [] you can access. For Ex:-

var a = '{
    "id": "149",
    "description": "Try"
}'

b = JSON.parse(a)

b['description'] or b.description FOr more reference you can study here

const dummy = {
  id : '1',
  description : 'Wow awesome'
};

console.log(dummy.description);

//-------------------------------------

const descData = dummy.description;

console.log(descData);

variableName['description'] or variableName.description

本文标签: javascriptAngular 4Get Value from JSON by KeyStack Overflow