private void savePermissions(Permissions p) { try { BatfishObjectMapper.prettyWriter().writeValue(_permsFile.toFile(), p); } catch (IOException e) { throw new BatfishException( String.format("Error saving permissions to '%s'", _permsFile.toAbsolutePath()), e); } }
public static void serializeAsJson(Path outputPath, Object object, String objectName) { try { BatfishObjectMapper.prettyWriter().writeValue(outputPath.toFile(), object); } catch (IOException e) { throw new BatfishException("Could not serialize " + objectName + " ", e); } }
public JSONObject getParsingResults(String networkName, String snapshotName) throws JsonProcessingException, JSONException { ParseVendorConfigurationAnswerElement pvcae = deserializeObject( getdirSnapshot(networkName, snapshotName) .resolve(Paths.get(BfConsts.RELPATH_OUTPUT, BfConsts.RELPATH_PARSE_ANSWER_PATH)), ParseVendorConfigurationAnswerElement.class); JSONObject warnings = new JSONObject(); SortedMap<String, Warnings> warningsMap = pvcae.getWarnings(); ObjectWriter writer = BatfishObjectMapper.prettyWriter(); for (String s : warningsMap.keySet()) { warnings.put(s, writer.writeValueAsString(warningsMap.get(s))); } return warnings; }