use of com.tms.homework.pavelgrigoryev.task18.jaxb.Gnome in project tms by igor-nasibyants.
the class MichaelJackson method toJackson.
public static void toJackson() throws IOException {
Gnome gnome = new Gnome();
gnome.setId(20);
gnome.setName("Shtepsel");
gnome.setAge(48);
ArrayList<Object> stupidList = new ArrayList<>();
stupidList.add(gnome);
stupidList.add(new Dwarf("Brann", "BronzeBeard", 17, 35, Role.MELEE_DAMAGE_DEALER));
stupidList.add(new Tank("T-14", "Армата", 2015, "military", 159644948965.46465));
stupidList.add(new IronMan("Tony Stark", 48, 1, "Money", 1000));
stupidList.add(new User(11, "Lolka", "lolka1576-13.lolka@apple.com", "lolk35aLOL1567"));
stupidList.add(new Houses(6, 99, 13, 70, "Переулок.Святого Антона"));
ObjectMapper mapper = new ObjectMapper();
String stupidListToJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(stupidList);
System.out.println(stupidListToJson);
FileWriter fileWriter = new FileWriter("json//MichaelJackson.json");
fileWriter.write(stupidListToJson);
fileWriter.close();
}
Aggregations