Class JsonPrinter

java.lang.Object
org.libxmq.imp.XMQPrinter
org.libxmq.imp.JsonPrinter

public class JsonPrinter extends XMQPrinter
Print the xmq DOM as json, a port of the printer in json.c (xmq_print_json). See JsonParser for the conventions used to store xml in json.
  • Constructor Details

    • JsonPrinter

      public JsonPrinter()
      Creates the json printer.
  • Method Details

    • toJson

      public String toJson(XmlDocument doc, OutputSettings os, boolean final_newline)
      Print the document as json, like xmq_print_json. The document is first fixed up (text and entities in an element are collapsed into one text).
      Parameters:
      doc - The document.
      os - The output settings.
      final_newline - Add a final newline.
      Returns:
      The json.
    • quote

      public static String quote(String s, boolean add_quotes)
      Quote a string like xmq_quote_as_c in text.c: backslash escapes for \\ \" \a \b \t \n \v \f \r and \xHH for other control characters.
      Parameters:
      s - The string.
      add_quotes - Add surrounding double quotes.
      Returns:
      The quoted string.