Gson傳遞和解析物件/集合
阿新 • • 發佈:2019-02-01
import java.io.IOException; import java.io.Serializable; public class Person implements Serializable { private int age; private String name; public Person(int age, String name) { super(); this.age = age; this.name = name; } private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.write(age); s.writeObject(name); } private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { age = s.readInt(); name = (String) s.readObject(); } @Override public String toString() { return "Person [age=" + age + ", name=" + name + "]"; } }
Gson解析Map集合