jsonDecode property

JsonObject jsonDecode

Decode a JSON String as JsonNode.

{@category decoder}

Implementation

JsonObject get jsonDecode {
  var chars = substring(
    indexOf("{") + 1,
    lastIndexOf("}") + 1,
  ).split("").normalizeSpaces;

  final data = <String, JsonNode>{};

  while (chars.isNotEmpty) {
    final pkey = _ProcessingKey(chars);
    final key = pkey.key;
    chars = pkey.chars;

    if (key == null) {
      continue;
    }

    final pval = _ProcessingValue(key, chars);
    final value = pval.value;
    chars = pval.chars;

    if (value != null) {
      data[key] = value;
    }
  }

  return JsonObject(data: data);
}