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.emailto 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
Jsonpathyou provided within theObject. If the path doesn't lead to any data, theResultwill be empty ornull.
Execution Flow,
Real-Life Examples,
-
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
- Object: A variable containing the details of a customer's order, for example:
- Result: The
Resultvariable will contain"[email protected]".
- Inputs:
-
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
- Object: A variable holding the details of a product, for example:
- Result: The
Resultvariable will contain99.99.
- Inputs:
-
Checking if an Item is In Stock
- Inputs:
- Object: The same product details as in Example 2.
- Jsonpath:
$.inStock
- Result: The
Resultvariable will containtrue.
- Inputs:
-
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
- Object: A variable containing user profile information, for example:
- Result: The
Resultvariable will containnull(or be empty), as there is no "phone" field within the "contact" section of this specific user object.
- Inputs: