英文:
How to get specific object from data
问题
Sure, here's the translation of the firstLanguage objects in a single variable:
{
"type": "Text",
"firstLanguage": {
"translation": "When the Constituent Assembly passed the Objective Resolution?",
"option_a": "14th February 1949",
"option_b": "12th March 1949",
"option_c": "9th June 1949",
"option_d": "15th August 1949",
"correct_answer": 4
}
}
Please note that I've combined the firstLanguage object into a single variable as requested.
英文:
{
type: 'Text',
firstLanguage: {
translation: 'When the Constituent Assembly passed the Objective Resolution?',
option_a: '14th February 1949',
option_b: '12th March 1949',
option_c: '9th June 1949',
option_d: '15th August 1949',
correct_answer: 4
},
secondLanguage: {
translation: 'متى أقرت الجمعية التأسيسية القرار الموضوعي؟',
option_a: '14th February 1949',
option_b: '12th March 1949',
option_c: '9th June 1949',
option_d: '15th August 1949',
correct_answer: 4
}
},
This is the data I am getting in reposne
I want to get the firstLanguage objects in a single variable . These are comming multiple
答案1
得分: 1
以下是已翻译的部分:
假设您获取到的数据是响应变量。在Node.js中,您可以这样做:
const response = {
type: 'Text',
firstLanguage: {
translation: '当制宪会议通过了客观决议时是什么时候?',
option_a: '1949年2月14日',
option_b: '1949年3月12日',
option_c: '1949年6月9日',
option_d: '1949年8月15日',
correct_answer: 4
},
secondLanguage: {
translation: 'متى أقرت الجمعية التأسيسية القرار الموضوعي؟',
option_a: '1949年2月14日',
option_b: '1949年3月12日',
option_c: '1949年6月9日',
option_d: '1949年8月15日',
correct_answer: 4
}
};
const firstLanguage = response.firstLanguage;
console.log(firstLanguage, 'firstLanguage');
感谢您的查询。
英文:
suppose you getting this data is response variable. you can do like this in node JS.
const response = {
type: 'Text',
firstLanguage: {
translation: 'When the Constituent Assembly passed the Objective Resolution?',
option_a: '14th February 1949',
option_b: '12th March 1949',
option_c: '9th June 1949',
option_d: '15th August 1949',
correct_answer: 4
},
secondLanguage: {
translation: 'متى أقرت الجمعية التأسيسية القرار الموضوعي؟',
option_a: '14th February 1949',
option_b: '12th March 1949',
option_c: '9th June 1949',
option_d: '15th August 1949',
correct_answer: 4
}
};
const firstLanguage = response.firstLanguage;
console.log(firstLanguage,'firstLanguage');
Add Comment for any query Thanks.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论