| .. | .. |
|---|
| 22 | 22 | */ |
|---|
| 23 | 23 | public class JsonUtils { |
|---|
| 24 | 24 | |
|---|
| 25 | | - private static final Logger log = LogManager.getLogger(JsonUtils.class); |
|---|
| 25 | + private static final Logger LOG = LogManager.getLogger(JsonUtils.class); |
|---|
| 26 | 26 | |
|---|
| 27 | 27 | final private static ObjectMapper MAPPER = new ObjectMapper(); |
|---|
| 28 | 28 | |
|---|
| .. | .. |
|---|
| 58 | 58 | } |
|---|
| 59 | 59 | return MAPPER.readValue(json, type); |
|---|
| 60 | 60 | } catch (JsonParseException e) { |
|---|
| 61 | | - log.error("Error parsing JSON string to obejct: {}", json, e); |
|---|
| 61 | + LOG.error("Error parsing JSON string to obejct: {}", json, e); |
|---|
| 62 | 62 | if (json.length() > 60) |
|---|
| 63 | 63 | json = json.substring(0, 50) + "..."; |
|---|
| 64 | 64 | throw new SeCurisException("Error parsing JSON string to object: " + json, e); |
|---|
| 65 | 65 | } catch (IOException e) { |
|---|
| 66 | | - log.error("Error parsing JSON string to object: {}", json, e); |
|---|
| 66 | + LOG.error("Error parsing JSON string to object: {}", json, e); |
|---|
| 67 | 67 | if (json.length() > 60) |
|---|
| 68 | 68 | json = json.substring(0, 50) + "..."; |
|---|
| 69 | 69 | throw new SeCurisException("Error parsing JSON string to object: " + json, e); |
|---|
| .. | .. |
|---|
| 85 | 85 | } |
|---|
| 86 | 86 | return MAPPER.writeValueAsString(obj); |
|---|
| 87 | 87 | } catch (JsonProcessingException e) { |
|---|
| 88 | | - log.error("Error formating JSON from object: {}", obj, e); |
|---|
| 88 | + LOG.error("Error formating JSON from object: {}", obj, e); |
|---|
| 89 | 89 | throw new SeCurisException("Error formating JSON from object: " + obj, e); |
|---|
| 90 | 90 | } catch (IOException e) { |
|---|
| 91 | | - log.error("Error formating JSON from object: {}", obj, e); |
|---|
| 91 | + LOG.error("Error formating JSON from object: {}", obj, e); |
|---|
| 92 | 92 | throw new SeCurisException("Error formating JSON from object: " + obj, e); |
|---|
| 93 | 93 | } |
|---|
| 94 | 94 | } |
|---|
| .. | .. |
|---|
| 111 | 111 | MAPPER.disable(SerializationConfig.Feature.INDENT_OUTPUT); |
|---|
| 112 | 112 | return json; |
|---|
| 113 | 113 | } catch (JsonProcessingException e) { |
|---|
| 114 | | - log.error("Error formating JSON from object: {}", obj, e); |
|---|
| 114 | + LOG.error("Error formating JSON from object: {}", obj, e); |
|---|
| 115 | 115 | throw new SeCurisException("Error formating JSON from object: " + obj, e); |
|---|
| 116 | 116 | } catch (IOException e) { |
|---|
| 117 | | - log.error("Error formating JSON from object: {}", obj, e); |
|---|
| 117 | + LOG.error("Error formating JSON from object: {}", obj, e); |
|---|
| 118 | 118 | throw new SeCurisException("Error formating JSON from object: " + obj, e); |
|---|
| 119 | 119 | } |
|---|
| 120 | 120 | } |
|---|
| .. | .. |
|---|
| 137 | 137 | } |
|---|
| 138 | 138 | return MAPPER.readValue(json, Map.class); |
|---|
| 139 | 139 | } catch (JsonParseException e) { |
|---|
| 140 | | - log.error("Error parsing JSON string to map: {}", json, e); |
|---|
| 140 | + LOG.error("Error parsing JSON string to map: {}", json, e); |
|---|
| 141 | 141 | throw e; |
|---|
| 142 | 142 | } catch (IOException e) { |
|---|
| 143 | | - log.error("Error parsing JSON string to map: {}", json, e); |
|---|
| 143 | + LOG.error("Error parsing JSON string to map: {}", json, e); |
|---|
| 144 | 144 | } |
|---|
| 145 | 145 | return null; |
|---|
| 146 | 146 | } |
|---|
| .. | .. |
|---|
| 160 | 160 | } |
|---|
| 161 | 161 | return MAPPER.writeValueAsString(map); |
|---|
| 162 | 162 | } catch (JsonProcessingException e) { |
|---|
| 163 | | - log.error("Error formating JSON from map: {}", map, e); |
|---|
| 163 | + LOG.error("Error formating JSON from map: {}", map, e); |
|---|
| 164 | 164 | } catch (IOException e) { |
|---|
| 165 | | - log.error("Error formating JSON from map: {}", map, e); |
|---|
| 165 | + LOG.error("Error formating JSON from map: {}", map, e); |
|---|
| 166 | 166 | } |
|---|
| 167 | 167 | |
|---|
| 168 | 168 | return null; |
|---|
| .. | .. |
|---|
| 182 | 182 | try { |
|---|
| 183 | 183 | return MAPPER.readValue(json, List.class); |
|---|
| 184 | 184 | } catch (JsonParseException e) { |
|---|
| 185 | | - log.error("Error converting JSON string to object {}", json, e); |
|---|
| 185 | + LOG.error("Error converting JSON string to object {}", json, e); |
|---|
| 186 | 186 | throw new SeCurisException("Error converting JSON to object", e); |
|---|
| 187 | 187 | } catch (IOException e) { |
|---|
| 188 | | - log.error("Error converting JSON string to object {}", json, e); |
|---|
| 188 | + LOG.error("Error converting JSON string to object {}", json, e); |
|---|
| 189 | 189 | throw new SeCurisException("Error converting JSON to object", e); |
|---|
| 190 | 190 | } |
|---|
| 191 | 191 | } |
|---|
| .. | .. |
|---|
| 206 | 206 | } catch (JsonParseException e) { |
|---|
| 207 | 207 | throw new SeCurisException("Error converting JSON to object", e); |
|---|
| 208 | 208 | } catch (IOException e) { |
|---|
| 209 | | - log.error("Error converting JSON to object", e); |
|---|
| 209 | + LOG.error("Error converting JSON to object", e); |
|---|
| 210 | 210 | throw new SeCurisException("Error converting JSON to object", e); |
|---|
| 211 | 211 | } |
|---|
| 212 | 212 | } |
|---|