jsonKeyCount method

int? jsonKeyCount({
  1. bool recursive = true,
})

Counts the number of keys in this JSON object

recursive Whether to count nested keys (defaults to true)

Returns the number of keys or null if JSON is invalid

Example:

final json = '{"name":"John","details":{"age":30,"city":"NYC"}}';
final count = json.jsonKeyCount(); // 4

Implementation

int? jsonKeyCount({bool recursive = true}) {
  return QJSONUtils.countKeys(this, recursive: recursive);
}