Skip to content

Commit c52547d

Browse files
authored
he laid hold on the dragon
And he laid hold on the dragon, that old serpent, which is the Devil, and Satan, and bound him a thousand years (Revelation 20:2)
1 parent e252f3c commit c52547d

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
//And he laid hold on the dragon, that old serpent, which is the Devil, and Satan, and bound him a thousand years (Revelation 20:2)
3+
4+
public class Solution {
5+
public static void main(String[] args) throws IOException {
6+
Cat cat = new Cat();
7+
cat.name = "Murka";
8+
cat.age = 5;
9+
cat.weight = 3;
10+
11+
StringWriter writer = new StringWriter();
12+
convertToJSON(writer, cat);
13+
System.out.println(writer.toString());
14+
}
15+
16+
public static void convertToJSON(StringWriter writer, Object object) throws IOException {
17+
ObjectMapper mapper = new ObjectMapper();
18+
mapper.writeValue(writer, object);
19+
}
20+
21+
22+
23+
@JsonAutoDetect
24+
public static class Cat {
25+
26+
@JsonProperty("wildAnimal")
27+
public String name;
28+
29+
@JsonIgnore
30+
public int age;
31+
32+
@JsonProperty("over")
33+
public int weight;
34+
35+
Cat() {
36+
}
37+
}
38+
}
39+
40+
/*
41+
Вторая сериализация в JSON
42+
43+
НЕОБХОДИМО: подключенные библиотеки Jackson Core, Bind и Annotation версии 2.6.1
44+
45+
46+
47+
Расставь JSON аннотации так, чтобы результат работы метода main был следующим
48+
49+
{"wildAnimal":"Murka","over":3}
50+
51+
52+
53+
54+
55+
Требования:
56+
57+
1. Поле name класса Cat должно быть отмечено аннотацией JsonProperty.
58+
59+
2. Поле age класса Cat должно быть отмечено аннотацией JsonIgnore.
60+
61+
3. Поле weight класса Cat должно быть отмечено аннотацией JsonProperty.
62+
63+
4. Значение (value) аннотации JsonProperty у поля name должно быть равно "wildAnimal".
64+
65+
5. Значение (value) аннотации JsonProperty у поля weight должно быть равно "over".
66+
*/

0 commit comments

Comments
 (0)