Package org.json

Class XMLParserConfiguration

java.lang.Object
org.json.XMLParserConfiguration

public class XMLParserConfiguration
extends java.lang.Object
Configuration object for the XML parser.
Author:
AylwardJ
  • Field Summary

    Fields 
    Modifier and Type Field Description
    java.lang.String cDataTagName
    The name of the key in a JSON Object that indicates a CDATA section.
    boolean convertNilAttributeToNull
    When parsing the XML into JSON, specifies if values with attribute xsi:nil="true" should be kept as attribute(false), or they should be converted to null(true)
    static XMLParserConfiguration KEEP_STRINGS
    Original configuration of the XML Parser except that values are kept as strings.
    boolean keepStrings
    When parsing the XML into JSON, specifies if values should be kept as strings (true), or if they should try to be guessed into JSON values (numeric, boolean, string)
    static XMLParserConfiguration ORIGINAL
    Original Configuration of the XML Parser.
  • Constructor Summary

    Constructors 
    Constructor Description
    XMLParserConfiguration()
    Default parser configuration.
    XMLParserConfiguration​(boolean keepStrings)
    Configure the parser string processing and use the default CDATA Tag Name as "content".
    XMLParserConfiguration​(boolean keepStrings, java.lang.String cDataTagName)
    Configure the parser to use custom settings.
    XMLParserConfiguration​(boolean keepStrings, java.lang.String cDataTagName, boolean convertNilAttributeToNull)
    Configure the parser to use custom settings.
    XMLParserConfiguration​(java.lang.String cDataTagName)
    Configure the parser string processing to try and convert XML values to JSON values and use the passed CDATA Tag Name the processing value.
  • Method Summary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ORIGINAL

      public static final XMLParserConfiguration ORIGINAL
      Original Configuration of the XML Parser.
    • KEEP_STRINGS

      public static final XMLParserConfiguration KEEP_STRINGS
      Original configuration of the XML Parser except that values are kept as strings.
    • keepStrings

      public final boolean keepStrings
      When parsing the XML into JSON, specifies if values should be kept as strings (true), or if they should try to be guessed into JSON values (numeric, boolean, string)
    • cDataTagName

      public final java.lang.String cDataTagName
      The name of the key in a JSON Object that indicates a CDATA section. Historically this has been the value "content" but can be changed. Use null to indicate no CDATA processing.
    • convertNilAttributeToNull

      public final boolean convertNilAttributeToNull
      When parsing the XML into JSON, specifies if values with attribute xsi:nil="true" should be kept as attribute(false), or they should be converted to null(true)
  • Constructor Details

    • XMLParserConfiguration

      public XMLParserConfiguration()
      Default parser configuration. Does not keep strings, and the CDATA Tag Name is "content".
    • XMLParserConfiguration

      public XMLParserConfiguration​(boolean keepStrings)
      Configure the parser string processing and use the default CDATA Tag Name as "content".
      Parameters:
      keepStrings - true to parse all values as string. false to try and convert XML string values into a JSON value.
    • XMLParserConfiguration

      public XMLParserConfiguration​(java.lang.String cDataTagName)
      Configure the parser string processing to try and convert XML values to JSON values and use the passed CDATA Tag Name the processing value. Pass null to disable CDATA processing
      Parameters:
      cDataTagName - null to disable CDATA processing. Any other value to use that value as the JSONObject key name to process as CDATA.
    • XMLParserConfiguration

      public XMLParserConfiguration​(boolean keepStrings, java.lang.String cDataTagName)
      Configure the parser to use custom settings.
      Parameters:
      keepStrings - true to parse all values as string. false to try and convert XML string values into a JSON value.
      cDataTagName - null to disable CDATA processing. Any other value to use that value as the JSONObject key name to process as CDATA.
    • XMLParserConfiguration

      public XMLParserConfiguration​(boolean keepStrings, java.lang.String cDataTagName, boolean convertNilAttributeToNull)
      Configure the parser to use custom settings.
      Parameters:
      keepStrings - true to parse all values as string. false to try and convert XML string values into a JSON value.
      cDataTagName - null to disable CDATA processing. Any other value to use that value as the JSONObject key name to process as CDATA.
      convertNilAttributeToNull - true to parse values with attribute xsi:nil="true" as null. false to parse values with attribute xsi:nil="true" as {"xsi:nil":true}.