Adjust for odlparent 3 / yangtools 2
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / jsonrpc / JsonUtils.java
1 /*
2  * Copyright (c) 2014, 2015 EBay Software Foundation and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.ovsdb.lib.jsonrpc;
9
10 import com.fasterxml.jackson.core.JsonProcessingException;
11 import com.fasterxml.jackson.databind.ObjectMapper;
12 import com.fasterxml.jackson.databind.ObjectWriter;
13
14 public final class JsonUtils {
15
16     private static ObjectMapper mapper = new ObjectMapper();
17     private static ObjectWriter prettyWriter = mapper.writerWithDefaultPrettyPrinter();
18
19     private JsonUtils() {
20     }
21
22     public static String prettyString(Object jsonNode) {
23         try {
24             return prettyWriter.writeValueAsString(jsonNode);
25         } catch (JsonProcessingException e) {
26             throw new RuntimeException(e);
27         }
28     }
29 }