Search in sources :

Example 1 with Gnome

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();
}
Also used : User(com.tms.homework.astakhnovich.task17.User) Houses(com.tms.homework.nikitaelenski.task14.Houses) Dwarf(com.tms.homework.pavelgrigoryev.task16.ironforged.Dwarf) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) Gnome(com.tms.homework.pavelgrigoryev.task18.jaxb.Gnome) IronMan(com.tms.homework.han.task18.hero.IronMan) Tank(com.tms.homework.pavelgrigoryev.task6.Tank) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 User (com.tms.homework.astakhnovich.task17.User)1 IronMan (com.tms.homework.han.task18.hero.IronMan)1 Houses (com.tms.homework.nikitaelenski.task14.Houses)1 Dwarf (com.tms.homework.pavelgrigoryev.task16.ironforged.Dwarf)1 Gnome (com.tms.homework.pavelgrigoryev.task18.jaxb.Gnome)1 Tank (com.tms.homework.pavelgrigoryev.task6.Tank)1 FileWriter (java.io.FileWriter)1 ArrayList (java.util.ArrayList)1