mapToNode static method
dynamic
mapToNode(
- Map<String, dynamic> json
)
Implementation
static Node mapToNode(Map<String, dynamic> json) {
dynamic node;
switch (json["type"]) {
case NodeType.ROOT:
node = RootNode(<Node>[]);
break;
case NodeType.ELEMENT:
node = ElementNode(tag: json["tag"]);
break;
case NodeType.TEXT:
node = TextNode(json["text"]);
break;
case NodeType.COMMENT:
node = CommentNode(json["text"]);
break;
}
if (json["children"] != null) {
node.children =
(json["children"] as List<dynamic>).map((c) => mapToNode(c)).toList();
}
if (json["attributes"] != null) {
node.attributes = (json["attributes"] as List<dynamic>)
.map((attr) =>
Attribute(attr["name"], attr["value"], attr["valueOriginal"]))
.toList();
}
return node;
}