public void write(ConfigurationMetadata metadata, OutputStream outputStream) throws IOException { JSONObject object = new JSONObject(); object.put("groups", toJsonArray(metadata, ItemType.GROUP)); object.put("properties", toJsonArray(metadata, ItemType.PROPERTY)); object.put("hints", toJsonArray(metadata.getHints())); outputStream.write(object.toString(2).getBytes(UTF_8)); }
public void write(ConfigurationMetadata metadata, OutputStream outputStream) throws IOException { try { JSONObject object = new JSONOrderedObject(); JsonConverter converter = new JsonConverter(); object.put("groups", converter.toJsonArray(metadata, ItemType.GROUP)); object.put("properties", converter.toJsonArray(metadata, ItemType.PROPERTY)); object.put("hints", converter.toJsonArray(metadata.getHints())); outputStream.write(object.toString(2).getBytes(UTF_8)); } catch (Exception ex) { if (ex instanceof IOException) { throw (IOException) ex; } if (ex instanceof RuntimeException) { throw (RuntimeException) ex; } throw new IllegalStateException(ex); } }