@Test public void mapToJsonBeanTest() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); final SimpleOutputBean bean = new SimpleOutputBean(); bean.setC(50); final String jsonBeanExpected = mapper.writeValueAsString(bean); final Map<String, Object> map = new HashMap<>(); map.put("c", 50); map.put("#update-count-1", 0); final String jsonBeanActual = JSONBeanUtil.toJSONBean(map); Assert.assertEquals(jsonBeanExpected, jsonBeanActual); }
@SuppressWarnings("unchecked") public static String toJSONBean(final List<Object> list) { String json = null; if (list.size() == 1) { final Map<String, Object> map = (Map<String, Object>) list.get(0); json = JSONBeanUtil.toJSONBean(map); } else if (list.size() > 1) { final StringBuilder stringBuilder = new StringBuilder("["); for (int i = 0; i < list.size(); i++) { final Map<String, Object> map = (Map<String, Object>) list.get(i); stringBuilder.append(JSONBeanUtil.toJSONBean(map)); if (i < list.size() - 1) { stringBuilder.append(','); } } stringBuilder.append(']'); json = stringBuilder.toString(); } return json; }
JSONBeanUtil { @SuppressWarnings("unchecked") public static String toJSONBean(final List<Object> list) { String json = null; if (list.size() == 1) { final Map<String, Object> map = (Map<String, Object>) list.get(0); json = JSONBeanUtil.toJSONBean(map); } else if (list.size() > 1) { final StringBuilder stringBuilder = new StringBuilder("["); for (int i = 0; i < list.size(); i++) { final Map<String, Object> map = (Map<String, Object>) list.get(i); stringBuilder.append(JSONBeanUtil.toJSONBean(map)); if (i < list.size() - 1) { stringBuilder.append(','); } } stringBuilder.append(']'); json = stringBuilder.toString(); } return json; } }
JSONBeanUtil { @SuppressWarnings("unchecked") public static String toJSONBean(final List<Object> list) { String json = null; if (list.size() == 1) { final Map<String, Object> map = (Map<String, Object>) list.get(0); json = JSONBeanUtil.toJSONBean(map); } else if (list.size() > 1) { final StringBuilder stringBuilder = new StringBuilder("["); for (int i = 0; i < list.size(); i++) { final Map<String, Object> map = (Map<String, Object>) list.get(i); stringBuilder.append(JSONBeanUtil.toJSONBean(map)); if (i < list.size() - 1) { stringBuilder.append(','); } } stringBuilder.append(']'); json = stringBuilder.toString(); } return json; } private  JSONBeanUtil(); }
JSONBeanUtil { @SuppressWarnings("unchecked") public static String toJSONBean(final List<Object> list) { String json = null; if (list.size() == 1) { final Map<String, Object> map = (Map<String, Object>) list.get(0); json = JSONBeanUtil.toJSONBean(map); } else if (list.size() > 1) { final StringBuilder stringBuilder = new StringBuilder("["); for (int i = 0; i < list.size(); i++) { final Map<String, Object> map = (Map<String, Object>) list.get(i); stringBuilder.append(JSONBeanUtil.toJSONBean(map)); if (i < list.size() - 1) { stringBuilder.append(','); } } stringBuilder.append(']'); json = stringBuilder.toString(); } return json; } 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 { @SuppressWarnings("unchecked") public static String toJSONBean(final List<Object> list) { String json = null; if (list.size() == 1) { final Map<String, Object> map = (Map<String, Object>) list.get(0); json = JSONBeanUtil.toJSONBean(map); } else if (list.size() > 1) { final StringBuilder stringBuilder = new StringBuilder("["); for (int i = 0; i < list.size(); i++) { final Map<String, Object> map = (Map<String, Object>) list.get(i); stringBuilder.append(JSONBeanUtil.toJSONBean(map)); if (i < list.size() - 1) { stringBuilder.append(','); } } stringBuilder.append(']'); json = stringBuilder.toString(); } return json; } 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);  }