-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
56 lines (31 loc) · 2.15 KB
/
Solution.java
File metadata and controls
56 lines (31 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//Blessed and holy is he that hath part in the first resurrection: on such the second death hath no power, but they shall be priests of God and of Christ, and shall reign with him a thousand years. (Revelation 20:6)
package com.javarush.task.task33.task3311;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.StringWriter;
/*
Странная ошибка
*/
public class Solution {
public static void main(String[] args) throws IOException {
StringWriter stringWriter = new StringWriter();
ObjectMapper objectMapper = new ObjectMapper();
String sampleJsonString = "{\"id\":1,\"name\":\"first\",\"KEY#1\":\"VALUE#1\",\"KEY#3\":\"VALUE#3\",\"KEY#2\":\"VALUE#2\"}";
RealBean realBean = objectMapper.readValue(sampleJsonString, RealBean.class);
objectMapper.writeValue(stringWriter, realBean);
System.out.println(stringWriter.toString());
}
}
/*
Странная ошибка
НЕОБХОДИМО: подключенные библиотеки Jackson Core, Bind и Annotation версии 2.6.1
В результате выполнения кода в методе main класса Solution возникает странная ошибка
при сериализации/десериализации в JSON. На экран должна быть выведена строка sampleJsonString,
а выводится не совсем она.
Разберись в чем проблема и исправь. Обрати внимание на класс RealBean.
Требования:
1. Метод getAdditionalMap должен быть отмечен одной подходящей Jackson аннотацией.
2. Сериализация элементов additionalMap в json должна происходить, как сериализация обычных полей класса.
3. Десериализация элементов additionalMap из json должна происходить, как десериализация обычных полей класса.
4. Метод main должен выводить данные на экран.
*/