iT邦幫忙

0

如何用VB.NET 可以將JSON上面某一行開始,拿取下面的資料再放入ARRAY上?

  • 分享至 

  • xImage

{
"id": 99999999999,
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxx",
"start_time": "2023-11-27T09:54:14Z",
"questions": [
{
"name": "Yee Cheung",
"email": "yeecheung@gmail.com",
"question_details": [
{
"question": "以下哪項風險因素?",
"answer": "D.\t以上皆是",
"polling_id": "__MZPUyT2222sOLv14J5Q",
"date_time": "1980-01-27 11:17:05"
},
{
"question": "下列的原因:",
"answer": "(d) 以上皆是 ",
"polling_id": "mdx9V5O12222jBtjaDUZQ",
"date_time": "1980-01-27 12:24:13"
}
],
"first_name": "Yee",
"last_name": "Cheung"
},
{
"name": "DAVID FUNG",
"email": "davidfun@yahoo.com.sg",
"question_details": [
{
"question": "以下哪項風險因素?",
"answer": "D.\t以上皆是",
"polling_id": "__MZPUy888yadsOLv14J5Q",
"date_time": "1980-11-27 11:17:10"
},
{
"question": "下列那個是滑倒絆倒的原因:",
"answer": "(d) 下列的原因 ",
"polling_id": "mdx9991Q_m03jBtjaDUZQ",
"date_time": "1980-11-27 12:24:16"
}
],
"first_name": "FUNG",
"last_name": "DAVID"
},
]
}

如何用VB.NET 可以由"questions"開始,拿取下面的資料再放入ARRAY上?

wdchiang iT邦新手 2 級 ‧ 2024-01-22 17:52:24 檢舉
先定義 class,不過我只寫 c#


public class Question
{
public string name { get; set; }
public string email { get; set; }
public List<QuestionDetail> question_details { get; set; }
public string first_name { get; set; }
public string last_name { get; set; }
}

public class QuestionDetail
{
public string question { get; set; }
public string answer { get; set; }
public string polling_id { get; set; }
public string date_time { get; set; }
}

public class Root
{
public long id { get; set; }
public string uuid { get; set; }
public DateTime start_time { get; set; }
public List<Question> questions { get; set; }
}
small IT iT邦新手 5 級 ‧ 2024-01-23 09:52:45 檢舉
Thank you your comment.
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

1
純真的人
iT邦大師 1 級 ‧ 2024-01-22 19:06:59

參考VB的Json轉Class方法~

https://ithelp.ithome.com.tw/questions/10213939

small IT iT邦新手 5 級 ‧ 2024-01-23 09:52:36 檢舉

Many thanks. Will try.

0
natalie321
iT邦見習生 ‧ 2024-03-18 12:16:07

You can use VB.NET to parse JSON data and extract an array of objects. Choose between Newtonsoft.Json for type safety and robustness, or System.Text.Json for a simpler approach, depending on your build now gg project needs.

我要發表回答

立即登入回答