decodeList property

Map<String, JsonNode> get decodeList

Decode List(s) by saving each value as JsonNode and storing their position as width/depth coordinates.

Example:

Given a List: [[ "hello", "goodbye" , "Sam", "Hanna"]]

Would result in the following Map: ".0.0.0.0" : "hello" ".0.0.0.1" : "goodbye" ".0.0.1.1" : "Sam" ".0.0.1.2" : "Hanna"

Implementation

Map<String, JsonNode> get decodeList {
  var depth = 1;
  var nextChild = runtimeType.toString();
  while (nextChild.startsWith("List<")) {
    nextChild =
        nextChild.removePrefixIfPresent("List<").removePostfixIfPresent(">");
    depth += 1;
  }

  return JsonArray(key: "foo", data: this)
      .stringify
      .replaceFirstMapped(RegExp('(^"[^"]+?":)'), (match) => "")
      .decodeJsonArray(maxDepth: depth);
}