Map buildNodeMap(input)

Source

static Map buildNodeMap(input) {
  Map create(value) {
    if (value is Map) {
      var m = <String, dynamic>{
        r"$is": "json"
      };

      for (String key in value.keys) {
        m[NodeNamer.createName(key)] = create(value[key]);
      }

      return m;
    } else if (value is List && value.every((e) => e is Map || e is List)) {
      var m = {};
      for (var i = 0; i < value.length; i++) {
        m[i.toString()] = create(value[i]);
      }
      return m;
    } else {
      return {
        r"$is": "json",
        r"$type": _guessType(value),
        "?_json": value
      };
    }
  }

  return create(input);
}