Java開発でObjectMapperを使ってwriteValue()のサンプルコード
下記コード
public static void main(String[] args) {
ArrayList<Busdevlopment> list=new ArrayList<Busdevlopment>();
Busdevlopment bd1=new Busdevlopment();
bd1.setName(“shunin");
bd1.setAge(26);
Busdevlopment bd2=new Busdevlopment();
bd2.setName(“tanto");
bd2.setAge(25);
list.add(bd1);
list.add(bd2);
StringWriter str=new StringWriter();
ObjectMapper objectMapper=new ObjectMapper();
try {
objectMapper.writeValue(str, list);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(str);
}