Open Kilda Java Documentation
JsonUtil.java
Go to the documentation of this file.
1 package org.openkilda.utility;
2 
3 import com.fasterxml.jackson.core.JsonParseException;
4 import com.fasterxml.jackson.core.JsonProcessingException;
5 import com.fasterxml.jackson.databind.JsonMappingException;
6 import com.fasterxml.jackson.databind.ObjectMapper;
7 
8 import java.io.IOException;
9 
10 public final class JsonUtil {
11 
12  private static ObjectMapper mapper = new ObjectMapper();
13 
14  private JsonUtil() {
15  }
16 
17 
25  public static String toString(final Object obj) throws JsonProcessingException {
26  return mapper.writeValueAsString(obj);
27  }
28 
29  public static <T> T toObject(final String data, final Class<T> objClass) throws JsonParseException, JsonMappingException, IOException {
30  return mapper.readValue(data, objClass);
31  }
32 }
static< T > T toObject(final String data, final Class< T > objClass)
Definition: JsonUtil.java:29
static String toString(final Object obj)
Definition: JsonUtil.java:25