containerKey method

bool containerKey(
  1. String keyName
)

json中是否包含指定的键 keyName键名称

Implementation

bool containerKey(String keyName) {
  if (keyName.isEmptyString) {
    return false;
  }
  if (this.isEmptyJson) {
    return false;
  }
  String regex = "(((\"" + keyName + "\")|('" + keyName + "')):(.*?)((\\,|\\})(\\s\\S)*))";
  var hasMatch = new RegExp(regex).hasMatch(this ?? "");
  return hasMatch;
}