codemelted.js Module
    Preparing search index...

    Function json_has_key

    • Determines if the specified object has the specified property.

      Parameters

      • params: { key: string; obj: object; should_throw?: boolean }
        • key: string

          The property to find.

        • obj: object

          The object to check.

        • Optionalshould_throw?: boolean

          Whether to throw instead of returning a value upon failure.

      Returns boolean

      true if property was found, false otherwise.

      // Check if object has field
      if (json_has_key({obj: obj, key: "id"})) {
      // Do your processing
      }

      // Throw if not expected
      json_has_key({obj: obj, key: "id", should_throw: true});