code: public String asYaml(String jsonStringFile) throws JsonProcessingException, IOException, FileNotFoundException {
  
          InputStream stream = getClass().getClassLoader().getResourceAsStream(jsonStringFile);
  
          Writer writer = new StringWriter();
          char[] buffer = new char[1024];
          Reader reader;
  
          if (stream == null) {
              this.getLogger().error("File does not exist: {}", jsonStringFile);
              throw new FileNotFoundException("ERR! File not found: " + jsonStringFile);
          }
  
          try {
              reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
              int n;
              while ((n = reader.read(buffer)) != -1) {
                  writer.write(buffer, 0, n);
              }
          } catch (Exception readerexception) {
              this.getLogger().error(readerexception.getMessage());
          } finally {
              try {
                  stream.close();
              } catch (Exception closeException) {
                  this.getLogger().error(closeException.getMessage());
              }
          }
          String text = writer.toString();
  
          String std = text.replace("\r", "").replace("\n", ""); // make sure we have unix style text regardless of the input
  
          // parse JSON
          JsonNode jsonNodeTree = new ObjectMapper().readTree(std);
          // save it as YAML
          String jsonAsYaml = new YAMLMapper().writeValueAsString(jsonNodeTree);
          return jsonAsYaml;
      }
docs: Method to convert one json to yaml file - backup&restore functionality
  <p>
  File will be placed on path /target/test-classes