interactsWith method

void interactsWith(
  1. String key
)
inherited

Records an interaction with the specified JSON property key.

For non-List JSON objects, tracks the root property name when accessing nested properties using dot notation. This ensures that property tracking works correctly even when using dot notation for deep property access.

Example:

// When accessing a nested property like 'user.profile.name'
// only the root key 'user' is marked as interacted
json.has('user.profile.name');

Implementation

void interactsWith(String key) {
  if (json is! List) {
    // For dot notation, we track the root property
    final prop = key.split('.').first;
    _interacted.add(prop);
  }
}