public class XML2JSON
extends java.lang.Object
To obtain a converter from a script use:
converter = XML2JSON.converter();
Modifier and Type | Method and Description |
---|---|
java.lang.String |
convert(java.lang.String xml)
Converts an XML string to a JSON string.
|
static XML2JSON |
converter()
Returns a XML2JSON converter.
|
void |
setArrayElements(java.lang.String[] elements)
Without direction JSON arrays are found by inspecting an XML element's
children to see if there are more than one and if they are the same
element type based on name.
|
void |
setForceTopLevelObject(boolean force)
Indicates whether the root XML element should be a named JSON object
inside an outer set of {}'s or treated anonymously as the root JSON
object represented with the outer {}'s.
|
void |
setIgnoreNamespaces(boolean ignore)
Indicates whether namespace declarations should be converted to
JSON attributes or not (ignored entirely).
|
void |
setRemoveNamespacePrefixes(boolean remove)
Indicates whether namespace prefixes in XML element names should be
removed when generating JSON names or not.
|
public static XML2JSON converter()
public java.lang.String convert(java.lang.String xml)
xml
- XML string.public void setRemoveNamespacePrefixes(boolean remove)
remove
- True if prefixes should be removed, false if not.public void setIgnoreNamespaces(boolean ignore)
ignore
- True if namespace declarations should be ignored,
false if they should be converted to attributes.public void setForceTopLevelObject(boolean force)
force
- True to include the top level XML as a named JSON object,
false to treat the root XML element anonymously.public void setArrayElements(java.lang.String[] elements)
elements
- list of XML element (local part) names.?? 2022 Perforce Software, All rights reserved
This software is the confidential and proprietary information of Perforce, Inc. and is subject to copyright protection under laws of the United States of America and other countries. The use of this software should be in accordance with the license agreement terms you entered into with Perforce, Inc.