Class JsonUtil

java.lang.Object
com.mirth.connect.userutil.JsonUtil

public class JsonUtil extends Object
Provides JSON utility methods.
  • Method Details

    • prettyPrint

      public static String prettyPrint(String input)
      Formats an JSON string with indented markup.
      Parameters:
      input - The JSON string to format.
      Returns:
      The formatted JSON string.
    • escape

      public static String escape(String input)
      Escapes any special JSON characters in the input.
      Parameters:
      input - The string to escape.
      Returns:
      The escaped string.
    • toXml

      public static String toXml(String jsonString) throws Exception
      Converts a JSON string to XML. This is the same as calling toXml(String jsonString, boolean multiplePI, boolean prettyPrint) with multiplePI = false and prettyPrint = false
      Parameters:
      jsonString - The JSON string to convert.
      Returns:
      The converted XML string.
      Throws:
      Exception - If the conversion failed.
    • toXml

      public static String toXml(String jsonString, boolean multiplePI, boolean prettyPrint) throws Exception
      Converts a JSON string to XML.
      Parameters:
      jsonString - The JSON string to convert.
      multiplePI - If true, the <? xml-multiple ... ?> processing instruction will be included for arrays.
      prettyPrint - Whether or not to fully indent the XML output.
      Returns:
      The converted XML string.
      Throws:
      Exception - If the conversion failed.