Xml2Json class
The Xml2Json class provides a means of parsing XML data and transforming the resultant element tree into the following popular JSON XML formats :-
Parker Badgerfish GData
The XML parser used is the one supplied by the xml package.
Functionality splits XML parsing out from transformation to JSON so as to allow clients to extract intermediate results if needed and to transform into more than one JSON XML format without re-parsing.
Note this package is intended for use as a one way transform only, it does not guarantee the resulting JSON string can be parsed back into valid XML.
See the individual transform classes for further documentation, however, all the transform functions convert XML data into JSON strings, so numbers such as become { "mynumber" : "150" } not { "mynumber" : 150 }
If you're translating from ATOM then Badgerfish and GData are the better ones to use as they are less lossy.
Usage is :-
Xml2Json jsonTransform = new Xml2Json(); jsonTransform.parse(xmlString); String jsonString = jsonTransform.toXxxxxxx();
Any exceptions thrown by the parser/transformers are re-thrown as instances of Xml2JsonException.
Constructors
- Xml2Json()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- xmlParserResult → XmlDocument?
-
The parser result
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parse(
String xmlString) → void - Parse an XML string
-
toBadgerfish(
{bool useLocalNameForNodes = false}) → String - Badgerfish transformer
-
toGData(
) → String - GData transformer
-
toOpenRally(
) → String - OpenRally transformer
-
toParker(
) → String - Parker transformer
-
toParkerWithAttrs(
{List< String> ? array}) → String - Parker with attributes transformer
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited