Answer the question
In order to leave comments, you need to log in
How to render JSON object received via API?
Friends, tell me. There is such a JSON object received from the server. I need to output by key, for example {s1_h1_text}. What is the best way to do this?
{
"text": {
"s1_h1_text": {
"id": 1,
"text": "заголовок 1-го уровня",
"lang_id": 1
},
"s1_h2_text": {
"id": 2,
"text": "заголовок 2-го уровня",
"lang_id": 1
},
"s1_h3_text": {
"id": 3,
"text": "заголовок 3-го уровня",
"lang_id": 1
}
}
}
Answer the question
In order to leave comments, you need to log in
So bring it out
const {s1_h1_text, s1_h2_text, s1_h3_text} = text;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question