Categories

Has Path

Check if a path exists using lodash _.has

Check if a property path exists on an object or array.

Highlights:

  • Uses lodash _.has
  • Checks own properties only
  • Returns true or false

Example:

  • Input: {"user":{"name":"Ada"}}
  • Path: user.name
  • Result: true

Enter a JSON object or array

Property path to check

Key Facts

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

Overview

The Has Path tool allows you to quickly verify if a specific property path exists within a JSON object or array using the reliable lodash _.has method.

When to Use

  • Validating the presence of nested keys in complex JSON data structures.
  • Checking if specific configuration settings or fields exist before processing data.
  • Debugging API responses to ensure required properties are present.

How It Works

  • Paste your JSON object or array into the input field.
  • Enter the dot-notation path you wish to verify (e.g., user.profile.id).
  • Click the check button to receive a true or false result based on whether the property exists as an own property of the object.

Use Cases

Verifying API response schemas during development.
Filtering data objects that contain specific nested attributes.
Ensuring configuration files contain all required keys before application startup.

Examples

1. Verify User Profile Field

Background
A developer is processing a large user dataset and needs to confirm if the 'email' field exists inside the 'contact' object for every entry.
Problem
Manually scanning large JSON files to check for missing keys is error-prone.
How to Use
Paste the user JSON into the input and enter 'contact.email' into the path field.
Example Config
Input: {"id": 1, "contact": {"email": "[email protected]"}}, Path: contact.email
Outcome
The tool returns 'true', confirming the field is present.

2. Check Array Index Existence

Background
An engineer needs to verify if a specific item exists at a certain index within a JSON array response.
Problem
Determining if an array has enough elements to avoid 'undefined' errors in code.
How to Use
Input the array and use the index path, such as '[2]'.
Example Config
Input: ["apple", "banana"], Path: [2]
Outcome
The tool returns 'false', indicating the third element does not exist.

Try with Samples

json

Related Hubs

FAQ

What does this tool check for?

It checks if a specific property path exists as an own property of the provided JSON object or array.

Does it check inherited properties?

No, it specifically uses lodash _.has, which only checks for own properties of the object.

What format should the path be in?

Use standard dot notation, such as 'data.items[0].name'.

Can I check arrays?

Yes, you can check for indices or properties within arrays using the same path syntax.

What is the output?

The tool returns a simple boolean value: true if the path exists, and false if it does not.

API Documentation

Request Endpoint

POST /en/api/tools/has-path

Request Parameters

Parameter Name Type Required Description
inputData textarea Yes Enter a JSON object or array
path text Yes Property path to check

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-has-path": {
      "name": "has-path",
      "description": "Check if a path exists using lodash _.has",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=has-path",
      "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]