Class YamlToJsonExtensions


  • public final class YamlToJsonExtensions
    extends java.lang.Object
    The class YamlToJsonExtensions helps to transform a given yaml string to a json string
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String toJson​(java.io.File yamlFile)
      Transforms the given yaml file into a json as String object
      static java.lang.String toJson​(java.io.File yamlFile, boolean prettyPrint)
      Transforms the given yaml file into a json as String object
      static void toJson​(java.io.File yamlFile, java.io.File resultJsonFile)
      Transforms the given yaml file into a json as File object
      static java.lang.String toJson​(java.lang.String yamlString)
      Transform the given yaml as String object to a json as String object
      static java.lang.String toJson​(java.lang.String yamlString, boolean prettyPrint)
      Transform the given yaml as String object to a json as String object
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toJson

        public static java.lang.String toJson​(java.lang.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 java.lang.String toJson​(java.lang.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 java.lang.String toJson​(java.io.File yamlFile)
                                       throws java.io.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:
        java.io.IOException - Signals that an I/O exception has occurred
      • toJson

        public static java.lang.String toJson​(java.io.File yamlFile,
                                              boolean prettyPrint)
                                       throws java.io.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:
        java.io.IOException - Signals that an I/O exception has occurred
      • toJson

        public static void toJson​(java.io.File yamlFile,
                                  java.io.File resultJsonFile)
                           throws java.io.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:
        java.io.IOException - Signals that an I/O exception has occurred