获取数据中的特定对象

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

How to get specific object from data

问题

Sure, here's the translation of the firstLanguage objects in a single variable:

  1. {
  2. "type": "Text",
  3. "firstLanguage": {
  4. "translation": "When the Constituent Assembly passed the Objective Resolution?",
  5. "option_a": "14th February 1949",
  6. "option_b": "12th March 1949",
  7. "option_c": "9th June 1949",
  8. "option_d": "15th August 1949",
  9. "correct_answer": 4
  10. }
  11. }

Please note that I've combined the firstLanguage object into a single variable as requested.

英文:
  1. {
  2. type: 'Text',
  3. firstLanguage: {
  4. translation: 'When the Constituent Assembly passed the Objective Resolution?',
  5. option_a: '14th February 1949',
  6. option_b: '12th March 1949',
  7. option_c: '9th June 1949',
  8. option_d: '15th August 1949',
  9. correct_answer: 4
  10. },
  11. secondLanguage: {
  12. translation: 'متى أقرت الجمعية التأسيسية القرار الموضوعي؟',
  13. option_a: '14th February 1949',
  14. option_b: '12th March 1949',
  15. option_c: '9th June 1949',
  16. option_d: '15th August 1949',
  17. correct_answer: 4
  18. }
  19. },

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中,您可以这样做:

  1. const response = {
  2. type: 'Text',
  3. firstLanguage: {
  4. translation: '当制宪会议通过了客观决议时是什么时候?',
  5. option_a: '1949年2月14日',
  6. option_b: '1949年3月12日',
  7. option_c: '1949年6月9日',
  8. option_d: '1949年8月15日',
  9. correct_answer: 4
  10. },
  11. secondLanguage: {
  12. translation: 'متى أقرت الجمعية التأسيسية القرار الموضوعي؟',
  13. option_a: '1949年2月14日',
  14. option_b: '1949年3月12日',
  15. option_c: '1949年6月9日',
  16. option_d: '1949年8月15日',
  17. correct_answer: 4
  18. }
  19. };
  20. const firstLanguage = response.firstLanguage;
  21. console.log(firstLanguage, 'firstLanguage');

感谢您的查询。

英文:

suppose you getting this data is response variable. you can do like this in node JS.

  1. const response = {
  2. type: 'Text',
  3. firstLanguage: {
  4. translation: 'When the Constituent Assembly passed the Objective Resolution?',
  5. option_a: '14th February 1949',
  6. option_b: '12th March 1949',
  7. option_c: '9th June 1949',
  8. option_d: '15th August 1949',
  9. correct_answer: 4
  10. },
  11. secondLanguage: {
  12. translation: 'متى أقرت الجمعية التأسيسية القرار الموضوعي؟',
  13. option_a: '14th February 1949',
  14. option_b: '12th March 1949',
  15. option_c: '9th June 1949',
  16. option_d: '15th August 1949',
  17. correct_answer: 4
  18. }
  19. };
  20. const firstLanguage = response.firstLanguage;
  21. 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:

确定