summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/nbi/apis/serviceorder/utils/JsonEntityConverter.java
blob: f63f9c5d546ff8b03aba45c004fe188218c8c6c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package org.onap.nbi.apis.serviceorder.utils;

import java.io.IOException;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
import com.fasterxml.jackson.databind.ObjectMapper;

public final class JsonEntityConverter {

    private static final ObjectMapper MAPPER = new ObjectMapper();

    public static String convertServiceOrderInfoToJson(ServiceOrderInfo serviceOrderInfo) {
        return MAPPER.valueToTree(serviceOrderInfo).toString();
    }

    public static ServiceOrderInfo convertJsonToServiceOrderInfo(String serviceOrderInfoJson) throws IOException {
        return MAPPER.treeToValue(MAPPER.readTree(serviceOrderInfoJson), ServiceOrderInfo.class);
    }
}