f89c4a7b81eb0464a818fd7538865daeffe9491c
[integration.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * PNF-REGISTRATION-HANDLER
4  * ================================================================================
5  * Copyright (C) 2018 Nokia. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.pnfsimulator.rest.util;
22
23 import com.fasterxml.jackson.core.JsonParser;
24 import com.fasterxml.jackson.core.ObjectCodec;
25 import com.fasterxml.jackson.databind.DeserializationContext;
26 import com.fasterxml.jackson.databind.JsonDeserializer;
27 import com.fasterxml.jackson.databind.JsonNode;
28 import com.google.gson.Gson;
29 import com.google.gson.JsonObject;
30
31 import java.io.IOException;
32
33 public class JsonObjectDeserializer extends JsonDeserializer<JsonObject> {
34     private Gson gson = new Gson();
35
36     @Override
37     public JsonObject deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
38         ObjectCodec oc = jsonParser.getCodec();
39         JsonNode node = oc.readTree(jsonParser);
40         return gson.fromJson(node.toString(), JsonObject.class);
41     }
42 }