use of com.bluenimble.platform.json.printers.YamlPrinter in project serverless by bluenimble.
the class SpecUtils method write.
public static void write(File apiFolder, JsonObject spec) throws CommandExecutionException {
File fApi = new File(apiFolder, "api." + BlueNimble.SpecLangs.Yaml);
if (fApi.exists()) {
// yaml
OutputStream out = null;
try {
out = new FileOutputStream(fApi);
YamlPrinter yaml = new YamlOutputStreamPrinter(out);
yaml.print(spec);
} catch (Exception ex) {
throw new CommandExecutionException(ex.getMessage(), ex);
} finally {
IOUtils.closeQuietly(out);
}
} else {
fApi = new File(apiFolder, "api." + BlueNimble.SpecLangs.Json);
if (fApi.exists()) {
try {
Json.store(spec, fApi);
} catch (Exception ex) {
throw new CommandExecutionException(ex.getMessage(), ex);
}
}
}
}
use of com.bluenimble.platform.json.printers.YamlPrinter in project serverless by bluenimble.
the class SpecUtils method toYaml.
public static void toYaml(String jsonText, OutputStream out) throws Exception {
JsonObject json = new JsonObject(jsonText);
YamlPrinter printer = new YamlOutputStreamPrinter(out);
printer.print(json);
}
Aggregations