M
M
magogo2019-02-25 11:40:46
JavaScript
magogo, 2019-02-25 11:40:46

How to output a specific element from JSON?

{
"name" : "admin",
"id" : "34",
"id_to" : "8"
}
For example, you need to display only the name value, how can this be done?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stimulate, 2019-02-25
@Stimulate

console.log(obj.name);

A
Andrey Okhotnikov, 2019-02-25
@tsepen

console.log({
"name" : "admin",
"id" : "34",
"id_to" : "8"
}.name)

or save to json variable and do like this
const obj = {
"name" : "admin",
"id" : "34",
"id_to" : "8"
}

console.log(obj.name)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question