Categories

Find Key

Find the first matching key using lodash _.findKey

Find the first key whose value matches a predicate.

Highlights:

  • Uses lodash _.findKey
  • Supports property, matchesProperty, or matches object predicates
  • Returns the first matching key or null

Example:

  • Object: {"a":{"active":false},"b":{"active":true}}
  • Predicate Type: Property
  • Property Name: active
  • Result: "b"

Enter a JSON object

Truthy property name when using property predicate

Property path for matchesProperty

JSON value to match

JSON object to match

Key Facts

Category
Data Processing
Input Types
textarea, select, text
Output Type
text
Sample Coverage
4
API Ready
Yes

Overview

Find Key is a precise utility tool designed to identify the first key in a JSON object that satisfies a specific condition using the lodash _.findKey method.

When to Use

  • When you need to locate the first occurrence of a key based on a specific property value.
  • When filtering complex JSON structures to find an entry that matches a nested object pattern.
  • When you need to verify if any item in a collection meets a criteria and retrieve its identifier.

How It Works

  • Paste your JSON object into the input field.
  • Select the predicate type that best fits your search criteria: Property, Matches Property, or Matches Object.
  • Define the specific property name, path, or object structure to match.
  • Execute the tool to return the first matching key or null if no match is found.

Use Cases

Identifying the ID of the first user in a database export who has an 'active' status set to true.
Locating the configuration key that matches a specific set of nested settings.
Quickly finding a product SKU in a large inventory object based on a specific attribute match.

Examples

1. Find Active User ID

Developer
Background
You have a large JSON object containing user profiles and need to find the first user who is currently active.
Problem
Manually scanning a large JSON file to find the first active user is error-prone.
How to Use
Input the user object, select 'Property' as the predicate type, and set the property name to 'active'.
Example Config
predicateType: 'property', predicateProperty: 'active'
Outcome
The tool returns the key of the first user object where 'active' is true.

2. Match Nested Configuration

System Administrator
Background
You have a complex configuration object and need to find which module has a specific 'enabled' setting.
Problem
The configuration is deeply nested, making it difficult to identify the module key manually.
How to Use
Use the 'Matches Object' predicate type and provide the target object structure.
Example Config
predicateType: 'matchesObject', matchObject: '{"enabled": true}'
Outcome
The tool returns the key of the first module that matches the provided configuration object.

Try with Samples

json

Related Hubs

FAQ

What library does this tool use?

This tool utilizes the lodash _.findKey function to perform searches.

What happens if no key matches the criteria?

The tool will return null.

Can I search for nested properties?

Yes, by using the 'Matches Property' predicate type and providing the correct path.

Does it return all matching keys?

No, it only returns the first key that satisfies the provided predicate.

Is the input format strictly JSON?

Yes, the input must be a valid JSON object.

API Documentation

Request Endpoint

POST /en/api/tools/find-key

Request Parameters

Parameter Name Type Required Description
objectInput textarea Yes Enter a JSON object
predicateType select No -
predicateProperty text No Truthy property name when using property predicate
matchPath text No Property path for matchesProperty
matchValue textarea No JSON value to match
matchObject textarea No JSON object to match

Response Format

{
  "result": "Processed text content",
  "error": "Error message (optional)",
  "message": "Notification message (optional)",
  "metadata": {
    "key": "value"
  }
}
Text: Text

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-find-key": {
      "name": "find-key",
      "description": "Find the first matching key using lodash _.findKey",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=find-key",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

If you encounter any issues, please contact us at [email protected]