public static String getRATJsonObjectHeader(String ratJson) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(); RATJsonObject jsonHeader = (RATJsonObject) mapper.readValue(ratJson, RATJsonObject.class); String output = mapper.writeValueAsString(jsonHeader.getHeader()); return output; }
public static String getRATJsonHeaderProperty(String ratJson, String propertyName) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(); RATJsonObject jsonHeader = (RATJsonObject) mapper.readValue(ratJson, RATJsonObject.class); String propertyValue = jsonHeader.getHeaderProperty(propertyName); return propertyValue; }
public static JsonHeader deserializeJsonHeader(final String ratJson) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(); RATJsonObject ratJsonObject = (RATJsonObject) mapper.readValue(ratJson, RATJsonObject.class); TypeFactory typeFactory = mapper.getTypeFactory(); MapType mapType = typeFactory.constructMapType(HashMap.class, String.class, String.class); HashMap<String, String> map = mapper.readValue(ratJsonObject.getHeader(), mapType); JsonHeader header = new JsonHeader(); header.setHeaderProperties(map); return header; }
public static String getHeader(RATJsonObject ratJson) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); String settings = mapper.writeValueAsString(ratJson.getHeader()); return settings; }