@Test public void parsePropertiesFromJSONBeanTest() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); final SimpleInputBean bean = new SimpleInputBean(); bean.setA(20); bean.setB(30); final String jsonBean = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(bean); final Properties properties = JSONBeanUtil.parsePropertiesFromJSONBean(jsonBean); Assert.assertTrue(properties.containsKey("a")); Assert.assertEquals("20", properties.get("a")); Assert.assertTrue(properties.containsKey("b")); Assert.assertEquals("30", properties.get("b")); }
public static Properties parsePropertiesFromJSONBean(final String json) { final Map<String, String> parsed; try { parsed = MAPPER.readerFor(STRING_STRING_MAP).readValue(json); } catch (final IOException e) { throw new IllegalArgumentException("Unable to parse given JSON", e); } final Properties ret = new Properties(); if (parsed != null) { parsed.entrySet().stream() .filter(e -> e.getKey() != null && e.getValue() != null) .forEach(e -> ret.put(e.getKey(), e.getValue())); } return ret; }
JSONBeanUtil { public static Properties parsePropertiesFromJSONBean(final String json) { final Map<String, String> parsed; try { parsed = MAPPER.readerFor(STRING_STRING_MAP).readValue(json); } catch (final IOException e) { throw new IllegalArgumentException("Unable to parse given JSON", e); } final Properties ret = new Properties(); if (parsed != null) { parsed.entrySet().stream() .filter(e -> e.getKey() != null && e.getValue() != null) .forEach(e -> ret.put(e.getKey(), e.getValue())); } return ret; } }
JSONBeanUtil { public static Properties parsePropertiesFromJSONBean(final String json) { final Map<String, String> parsed; try { parsed = MAPPER.readerFor(STRING_STRING_MAP).readValue(json); } catch (final IOException e) { throw new IllegalArgumentException("Unable to parse given JSON", e); } final Properties ret = new Properties(); if (parsed != null) { parsed.entrySet().stream() .filter(e -> e.getKey() != null && e.getValue() != null) .forEach(e -> ret.put(e.getKey(), e.getValue())); } return ret; } private  JSONBeanUtil(); }
JSONBeanUtil { public static Properties parsePropertiesFromJSONBean(final String json) { final Map<String, String> parsed; try { parsed = MAPPER.readerFor(STRING_STRING_MAP).readValue(json); } catch (final IOException e) { throw new IllegalArgumentException("Unable to parse given JSON", e); } final Properties ret = new Properties(); if (parsed != null) { parsed.entrySet().stream() .filter(e -> e.getKey() != null && e.getValue() != null) .forEach(e -> ret.put(e.getKey(), e.getValue())); } return ret; } private  JSONBeanUtil(); static Properties parsePropertiesFromJSONBean(final String json); static Map<String, SqlParameterValue> parseSqlParametersFromJSONBean(final String json, final Map<String, Integer> jdbcTypeMap); @SuppressWarnings("unchecked") static String toJSONBean(final List<Object> list); static String toJSONBean(final Map<String, Object> map); static List<String> toJSONBeans(Message in); static List<String> toJSONBeansFromHeader(Message in, String autoIncrementColumnName); }
JSONBeanUtil { public static Properties parsePropertiesFromJSONBean(final String json) { final Map<String, String> parsed; try { parsed = MAPPER.readerFor(STRING_STRING_MAP).readValue(json); } catch (final IOException e) { throw new IllegalArgumentException("Unable to parse given JSON", e); } final Properties ret = new Properties(); if (parsed != null) { parsed.entrySet().stream() .filter(e -> e.getKey() != null && e.getValue() != null) .forEach(e -> ret.put(e.getKey(), e.getValue())); } return ret; } private  JSONBeanUtil(); static Properties parsePropertiesFromJSONBean(final String json); static Map<String, SqlParameterValue> parseSqlParametersFromJSONBean(final String json, final Map<String, Integer> jdbcTypeMap); @SuppressWarnings("unchecked") static String toJSONBean(final List<Object> list); static String toJSONBean(final Map<String, Object> map); static List<String> toJSONBeans(Message in); static List<String> toJSONBeansFromHeader(Message in, String autoIncrementColumnName);  }