static <T> T fromJSON(String json, Class<T> clzz) { try { return om.readValue(json, clzz); } catch (IOException e) { throw new RuntimeException(e); } }
/** * * @param json the json representation * @return the parsed object */ public static ParquetMetadata fromJSON(String json) { try { return objectMapper.readValue(new StringReader(json), ParquetMetadata.class); } catch (JsonParseException e) { throw new RuntimeException(e); } catch (JsonMappingException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
/** * parses JSON into the given class * * @param json * @param clazz * @return */ public static <T extends SummaryData> T fromJSON(String json, Class<T> clazz) { try { return objectMapper.readValue(new StringReader(json), clazz); } catch (JsonParseException e) { throw new RuntimeException(e); } catch (JsonMappingException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
private static void compareJson(LinkedList<String> arguments) throws IOException { String oldJsonPath = arguments.pollFirst(); String newJsonPath = arguments.pollFirst(); File oldJsonFile = new File(oldJsonPath); checkExist(oldJsonFile); File newJsonFile = new File(newJsonPath); checkExist(newJsonFile); ObjectMapper mapper = new ObjectMapper(); ThriftType.StructType oldStruct = mapper.readValue(oldJsonFile, ThriftType.StructType.class); ThriftType.StructType newStruct = mapper.readValue(newJsonFile, ThriftType.StructType.class); CompatibilityReport report = new CompatibilityChecker().checkCompatibility(oldStruct, newStruct); if (!report.isCompatible) { System.err.println("schema not compatible"); System.err.println(report.getMessages()); System.exit(1); } System.out.println("[success] schema is compatible"); }