Add serviceOrder rest services
[externalapi/nbi.git] / src / main / java / org / onap / nbi / apis / serviceorder / utils / JsonEntityConverter.java
1 package org.onap.nbi.apis.serviceorder.utils;
2
3 import java.io.IOException;
4 import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
5 import com.fasterxml.jackson.databind.ObjectMapper;
6
7 public final class JsonEntityConverter {
8
9     private static final ObjectMapper MAPPER = new ObjectMapper();
10
11     public static String convertServiceOrderInfoToJson(ServiceOrderInfo serviceOrderInfo) {
12         return MAPPER.valueToTree(serviceOrderInfo).toString();
13     }
14
15     public static ServiceOrderInfo convertJsonToServiceOrderInfo(String serviceOrderInfoJson) throws IOException {
16         return MAPPER.treeToValue(MAPPER.readTree(serviceOrderInfoJson), ServiceOrderInfo.class);
17     }
18 }