Class YamlToJsonExtensions

java.lang.Object
io.github.astrapi69.yaml.YamlToJsonExtensions

public final class YamlToJsonExtensions extends Object
The class YamlToJsonExtensions helps to transform a given yaml string to a json string
  • Method Details

    • toJson

      public static String toJson(String yamlString) throws com.fasterxml.jackson.core.JsonProcessingException
      Transform the given yaml as String object to a json as String object
      Parameters:
      yamlString - the yaml as String object
      Returns:
      the transformed json as String object
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - If an error occurs when converting object to String
    • toJson

      public static String toJson(String yamlString, boolean prettyPrint) throws com.fasterxml.jackson.core.JsonProcessingException
      Transform the given yaml as String object to a json as String object
      Parameters:
      yamlString - the yaml as String object
      prettyPrint - the flag that indicates if the output json string should be pretty formatted
      Returns:
      the transformed json as String object
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - If an error occurs when converting object to String
    • toJson

      public static String toJson(File yamlFile) throws IOException
      Transforms the given yaml file into a json as String object
      Parameters:
      yamlFile - the yaml file
      Returns:
      the transformed json as String object
      Throws:
      IOException - Signals that an I/O exception has occurred
    • toJson

      public static String toJson(File yamlFile, boolean prettyPrint) throws IOException
      Transforms the given yaml file into a json as String object
      Parameters:
      yamlFile - the yaml file
      prettyPrint - the flag that indicates if the output json string should be pretty formatted
      Returns:
      the transformed json as String object
      Throws:
      IOException - Signals that an I/O exception has occurred
    • toJson

      public static void toJson(File yamlFile, File resultJsonFile) throws IOException
      Transforms the given yaml file into a json as File object
      Parameters:
      yamlFile - the yaml file
      resultJsonFile - the result file in json format
      Throws:
      IOException - Signals that an I/O exception has occurred