[{"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"]}]
1 回答
慕尼黑5688855
TA贡献1848条经验 获得超2个赞
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()); } }
添加回答
举报
0/150
提交
取消