java json解析(麻烦写出具体步骤)

[{
"courseID": "AAS 100",
"courseName": "Intro Asian American Studies",
"instructors": ["Ngo, F"]
}, {
"courseID": "ACCY 301",
"courseName": "Atg Measurement & Disclosure",
"instructors": ["Sougiannis, T", "Wang, Z", "Anderson, S", "Li, W"]
}]

慕姐8265434
浏览 720回答 1
1回答

慕尼黑5688855

import java.util.List; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; public class main{     public static void main ( String[] args ){         String jsonData = "[{" +          "\"courseID\": \"AAS 100\"," +          "\"courseName\": \"Intro Asian American Studies\"," +         "\"instructors\": [\"Ngo, F\"]" +         "}, {" +         "\"courseID\": \"ACCY 301\"," +         "\"courseName\": \"Atg Measurement & Disclosure\"," +         "\"instructors\": [\"Sougiannis, T\", \"Wang, Z\", \"Anderson, S\", \"Li, W\"]" +         "}]";         Gson gson = new Gson();         List jsonList = gson.fromJson(jsonData, new TypeToken<List>() {         }.getType());         System.out.print(jsonList.toString());     } }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java