decodeObject function

Map<String, Object?> decodeObject(
  1. LineCursor cursor,
  2. int baseDepth,
  3. ResolvedDecodeOptions options
)

Decodes an object from the cursor

Implementation

Map<String, Object?> decodeObject(
    LineCursor cursor, int baseDepth, ResolvedDecodeOptions options) {
  final obj = <String, Object?>{};

  while (!cursor.atEnd()) {
    final line = cursor.peek();
    if (line == null || line.depth < baseDepth) {
      break;
    }

    if (line.depth == baseDepth) {
      final (key, value) = decodeKeyValuePair(line, cursor, baseDepth, options);
      obj[key] = value;
    } else {
      break;
    }
  }

  return obj;
}