xmlToJson static method

String xmlToJson(
  1. String xml, {
  2. bool pretty = false,
  3. bool includeRoot = true,
})

Implementation

static String xmlToJson(String xml, {bool pretty = false, bool includeRoot = true}) {
  final _XmlNode root = _parseXml(xml);
  final dynamic value = _xmlToValue(root);
  final Object? result = includeRoot ? <String, dynamic>{root.name: value} : value;
  return pretty ? const JsonEncoder.withIndent("  ").convert(result) : jsonEncode(result);
}