获取数据中的特定对象

huangapple go评论81阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年1月3日 17:25:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/74991343.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定