-
- private static class MapToListSerializer extends JsonSerializer<Map<?, ?>> {
-
- @Override
- public void serialize(final Map<?, ?> value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException {
- jgen.writeObject(value.values());
- }
- }
-
- private static class ContactsDeserializer extends JsonDeserializer<Map<String, ContactInfo>> {
-
- @Override
- public Map<String, ContactInfo> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
- Map<String, ContactInfo> contacts = new HashMap<>();
- JsonNode node = jsonParser.getCodec().readTree(jsonParser);
- for (JsonNode n : node) {
- ContactInfo c = jsonProcessor.treeToValue(n, ContactInfo.class);
- contacts.put(c.number, c);
- }
-
- return contacts;
- }
- }