extract static method

Object? extract(
  1. String text
)

Extracts the first JSON object or array from text.

Handles fenced blocks (```json or ```), leading and trailing prose, and nested braces inside strings. Returns null when no valid JSON is present.

Implementation

static Object? extract(String text) {
  for (final candidate in _candidates(text)) {
    final decoded = _tryDecode(candidate);
    if (decoded != null) return decoded;
  }
  return null;
}