Ask AI
Skip to main content

Get value from object

Function: Get value from object

This function helps you extract a specific piece of information from a larger collection of data, often referred to as an "object." Think of an object as a structured record, like a customer profile, an order form, or a product listing, which contains various details. You tell the system exactly where to look within this object using a special "address" called a Jsonpath, and it will retrieve that specific value for you.

Input,

  • Object (Type: OBJECT) The main collection of data (like a record or a data entry) from which you want to extract information. This could be a customer's details, a product's specifications, or any other structured data you're working with.
  • Jsonpath (Type: STRING) This is the "address" or "path" you provide as text to pinpoint the exact piece of information you want to retrieve within your Object. For example, if your object contains customer details, a Jsonpath might be $.customer.email to get the customer's email address. This input is required.

Output,

  • Result (Type: VARIABLE) This is the specific piece of data that was found at the Jsonpath you provided within the Object. If the path doesn't lead to any data, the Result will be empty or null.

Execution Flow,

Real-Life Examples,

  1. Extracting a Customer's Email from an Order

    • Inputs:
      • Object: A variable containing the details of a customer's order, for example:
        \{
        "orderId": "ORD12345",
        "customer": \{
        "name": "Alice Smith",
        "email": "[email protected]",
        "phone": "555-1234"
        \},
        "totalAmount": 150.75
        \}
      • Jsonpath: $.customer.email
    • Result: The Result variable will contain "[email protected]".
  2. Getting a Product's Price from a Product Record

    • Inputs:
      • Object: A variable holding the details of a product, for example:
        \{
        "productId": "PROD001",
        "name": "Wireless Headphones",
        "category": "Electronics",
        "price": 99.99,
        "inStock": true
        \}
      • Jsonpath: $.price
    • Result: The Result variable will contain 99.99.
  3. Checking if an Item is In Stock

    • Inputs:
      • Object: The same product details as in Example 2.
      • Jsonpath: $.inStock
    • Result: The Result variable will contain true.
  4. Attempting to Retrieve a Non-Existent Detail

    • Inputs:
      • Object: A variable containing user profile information, for example:
        \{
        "userId": "USER007",
        "username": "JamesBond",
        "contact": \{
        "email": "[email protected]"
        \}
        \}
      • Jsonpath: $.contact.phone
    • Result: The Result variable will contain null (or be empty), as there is no "phone" field within the "contact" section of this specific user object.