标签:studio public 读取 ica sse 建立 nts csharp inf
public class Student { @PrimaryKey @NonNull @ColumnInfo(name = "stu_id") private long stu_id; @NonNull @ColumnInfo(name = "name") private String name; //身份证 @ColumnInfo(name = "ID") private String ID; //性别 0-男 1-女 @ColumnInfo(name = "sex") private int sex; }
[ { "stu_id":1000, "ID": "410923198910162546", "name": "张三", "sex":1 }, { "stu_id":1001, "ID": "410923198910162545", "name": "李四", "sex":2 } ]
InputStream inputStream = getApplicationContext().getAssets().open("students_file.json"); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); JsonReader jsonReader = new JsonReader(inputStreamReader); Gson gson = new Gson(); Type type = new TypeToken<List<Student>>(){}.getType(); List<Student> mstus=gson.fromJson(jsonReader, type);
Gson使用google的JsonReader读取Json文件并转化成对象
标签:studio public 读取 ica sse 建立 nts csharp inf
原文地址:https://www.cnblogs.com/endian11/p/11929207.html