Code ReOrganization and Re-Architecture changes
[ovsdb.git] / library / src / main / java / org / opendaylight / ovsdb / lib / jsonrpc / JsonUtils.java
1 /*
2  * Copyright (C) 2014 EBay Software Foundation
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  * Authors : Ashwin Raveendran
9  */
10 package org.opendaylight.ovsdb.lib.jsonrpc;
11
12 import com.fasterxml.jackson.core.JsonProcessingException;
13 import com.fasterxml.jackson.databind.ObjectMapper;
14 import com.fasterxml.jackson.databind.ObjectWriter;
15
16
17 public class JsonUtils {
18
19     static ObjectMapper mapper = new ObjectMapper();
20
21     static ObjectWriter prettyWriter = mapper.writerWithDefaultPrettyPrinter();
22
23     public static String prettyString(Object jsonNode){
24         try {
25             return prettyWriter.writeValueAsString(jsonNode);
26         } catch (JsonProcessingException e) {
27             throw new RuntimeException(e);
28         }
29     }
30 }