分别使用JSON和序列化反序列化实现
public class Person implements Cloneable {
private String name;
private String no;
private Person son;
@Override
public Object clone() {
return null;
}
}
有一个类Game
public class Game {
private String name;
private double star;
private int size;
private double money;
}
请创建对象,并将对象转换成JSON字符串输入到文件game.txt
中。
有这样一个JSON文件和一个Student类,请将它转换成Student对象,并打印出来。
{
"id" : 1,
"name" : "枫原万叶",
"age" : 20,
"password" : "123456",
"hobby" : ["唱歌", "游戏", "学习"]
}
public class Student {
private int id;
private String name;
private int age;
private String password;
private String[] hobby;
}
powered by kaifamiao