@Test public void testLightEncodingMultiple() throws IOException { String jsonbOrigin = new String(Files.readAllBytes(Paths.get("src/test/resources/samples/Multiple_db_encoding.json"))); Map translated = new LightRawJsonEncoder(jsonbOrigin).encodeContentAsMap("data"); assertNotNull(translated); }
public Map encodeContentAsMap(String root){ GsonBuilder gsondb = EncodeUtil.getGsonBuilderInstance(); if (jsonbOrigin.startsWith("[")){ jsonbOrigin = jsonbOrigin.trim().substring(1, jsonbOrigin.length()-1); } Map<String, Object> fromDB = new CompositionMap(gsondb.create().fromJson(jsonbOrigin, Map.class)).restructure(); GsonBuilder gsonRaw = EncodeUtil.getGsonBuilderInstance(I_DvTypeAdapter.AdapterType.DBJSON2RAWJSON); String raw = gsonRaw.create().toJson(fromDB); GsonBuilder gsonBuilder = EncodeUtil.getGsonBuilderInstance(); Map retmap = gsonBuilder.create().fromJson(raw, Map.class); return retmap; }
LightRawJsonEncoder { public Map encodeContentAsMap(String root){ GsonBuilder gsondb = EncodeUtil.getGsonBuilderInstance(); if (jsonbOrigin.startsWith("[")){ jsonbOrigin = jsonbOrigin.trim().substring(1, jsonbOrigin.length()-1); } Map<String, Object> fromDB = new CompositionMap(gsondb.create().fromJson(jsonbOrigin, Map.class)).restructure(); GsonBuilder gsonRaw = EncodeUtil.getGsonBuilderInstance(I_DvTypeAdapter.AdapterType.DBJSON2RAWJSON); String raw = gsonRaw.create().toJson(fromDB); GsonBuilder gsonBuilder = EncodeUtil.getGsonBuilderInstance(); Map retmap = gsonBuilder.create().fromJson(raw, Map.class); return retmap; } }
LightRawJsonEncoder { public Map encodeContentAsMap(String root){ GsonBuilder gsondb = EncodeUtil.getGsonBuilderInstance(); if (jsonbOrigin.startsWith("[")){ jsonbOrigin = jsonbOrigin.trim().substring(1, jsonbOrigin.length()-1); } Map<String, Object> fromDB = new CompositionMap(gsondb.create().fromJson(jsonbOrigin, Map.class)).restructure(); GsonBuilder gsonRaw = EncodeUtil.getGsonBuilderInstance(I_DvTypeAdapter.AdapterType.DBJSON2RAWJSON); String raw = gsonRaw.create().toJson(fromDB); GsonBuilder gsonBuilder = EncodeUtil.getGsonBuilderInstance(); Map retmap = gsonBuilder.create().fromJson(raw, Map.class); return retmap; } LightRawJsonEncoder(String jsonbOrigin); }
LightRawJsonEncoder { public Map encodeContentAsMap(String root){ GsonBuilder gsondb = EncodeUtil.getGsonBuilderInstance(); if (jsonbOrigin.startsWith("[")){ jsonbOrigin = jsonbOrigin.trim().substring(1, jsonbOrigin.length()-1); } Map<String, Object> fromDB = new CompositionMap(gsondb.create().fromJson(jsonbOrigin, Map.class)).restructure(); GsonBuilder gsonRaw = EncodeUtil.getGsonBuilderInstance(I_DvTypeAdapter.AdapterType.DBJSON2RAWJSON); String raw = gsonRaw.create().toJson(fromDB); GsonBuilder gsonBuilder = EncodeUtil.getGsonBuilderInstance(); Map retmap = gsonBuilder.create().fromJson(raw, Map.class); return retmap; } LightRawJsonEncoder(String jsonbOrigin); String encodeContentAsString(String root); Map encodeContentAsMap(String root); }
LightRawJsonEncoder { public Map encodeContentAsMap(String root){ GsonBuilder gsondb = EncodeUtil.getGsonBuilderInstance(); if (jsonbOrigin.startsWith("[")){ jsonbOrigin = jsonbOrigin.trim().substring(1, jsonbOrigin.length()-1); } Map<String, Object> fromDB = new CompositionMap(gsondb.create().fromJson(jsonbOrigin, Map.class)).restructure(); GsonBuilder gsonRaw = EncodeUtil.getGsonBuilderInstance(I_DvTypeAdapter.AdapterType.DBJSON2RAWJSON); String raw = gsonRaw.create().toJson(fromDB); GsonBuilder gsonBuilder = EncodeUtil.getGsonBuilderInstance(); Map retmap = gsonBuilder.create().fromJson(raw, Map.class); return retmap; } LightRawJsonEncoder(String jsonbOrigin); String encodeContentAsString(String root); Map encodeContentAsMap(String root);  }