Fairly straightforward goal: Return the value of the level
(array key) for the lowest value in the key of the array item cost_excl_tax
(ive included copy/paste of a json module which outputs the data as displayed here - see bottom of post, you can copy the JSON and paste into any scenario)
Example structure of a collection/array:
In this example which returns 5 collections the lowest value of the key cost_excl_tax
is the 5th item in the collection with the value 5.69
… so I’d want to “return” the value of the level
- in this case “MAIL”.
I feel like I had a good handle of get/map functions but honestly I can never seem to fully grasp how to do this correctly… I hope Make creates an AI co pilot for creation of these complex functions someday hah.
Thoughts? Much appreciated!
The full array (example)
[
{
"id": 29,
"carrier_service_name": "FedEx 2 Day",
"level": "EXPEDITED",
"postbox_ok": false,
"home_only": false,
"business_only": false,
"traceable": true,
"transit_time": 2,
"cost_excl_tax": 13.69,
"currency": "USD",
"is_active": true,
"total_days_min": 7,
"total_days_max": 9,
"min_dispatch_date": "2024-02-09",
"max_dispatch_date": "2024-02-13",
"min_delivery_date": "2024-02-13",
"max_delivery_date": "2024-02-15"
},
{
"id": 31,
"carrier_service_name": "FedEx Home",
"level": "GROUND_HD",
"postbox_ok": false,
"home_only": true,
"business_only": false,
"traceable": true,
"transit_time": 5,
"cost_excl_tax": 11.69,
"currency": "USD",
"is_active": true,
"total_days_min": 10,
"total_days_max": 12,
"min_dispatch_date": "2024-02-09",
"max_dispatch_date": "2024-02-13",
"min_delivery_date": "2024-02-16",
"max_delivery_date": "2024-02-20"
},
{
"id": 32,
"carrier_service_name": "FedEx Standard Overnight",
"level": "EXPRESS",
"postbox_ok": false,
"home_only": false,
"business_only": false,
"traceable": true,
"transit_time": 1,
"cost_excl_tax": 23.69,
"currency": "USD",
"is_active": true,
"total_days_min": 6,
"total_days_max": 8,
"min_dispatch_date": "2024-02-09",
"max_dispatch_date": "2024-02-13",
"min_delivery_date": "2024-02-12",
"max_delivery_date": "2024-02-14"
},
{
"id": 34,
"carrier_service_name": "USPS Priority Mail",
"level": "PRIORITY_MAIL",
"postbox_ok": true,
"home_only": false,
"business_only": false,
"traceable": true,
"transit_time": 5,
"cost_excl_tax": 11.94,
"currency": "USD",
"is_active": true,
"total_days_min": 10,
"total_days_max": 12,
"min_dispatch_date": "2024-02-09",
"max_dispatch_date": "2024-02-13",
"min_delivery_date": "2024-02-16",
"max_delivery_date": "2024-02-20"
},
{
"id": 1241,
"carrier_service_name": "UPS Mail Innovation",
"level": "MAIL",
"postbox_ok": true,
"home_only": false,
"business_only": false,
"traceable": true,
"transit_time": 7,
"cost_excl_tax": 5.69,
"currency": "USD",
"is_active": true,
"total_days_min": 12,
"total_days_max": 14,
"min_dispatch_date": "2024-02-09",
"max_dispatch_date": "2024-02-13",
"min_delivery_date": "2024-02-20",
"max_delivery_date": "2024-02-22"
}
]
For Testing:
Copy/Paste JSON module which can be used for testing
{
"subflows": [
{
"flow": [
{
"id": 16,
"module": "json:ParseJSON",
"version": 1,
"parameters": {
"type": ""
},
"mapper": {
"json": "[\n {\n \"data\": [\n {\n \"id\": 29,\n \"carrier_service_name\": \"FedEx 2 Day\",\n \"level\": \"EXPEDITED\",\n \"postbox_ok\": false,\n \"home_only\": false,\n \"business_only\": false,\n \"traceable\": true,\n \"transit_time\": 2,\n \"cost_excl_tax\": 13.69,\n \"currency\": \"USD\",\n \"is_active\": true,\n \"total_days_min\": 7,\n \"total_days_max\": 9,\n \"min_dispatch_date\": \"2024-02-09\",\n \"max_dispatch_date\": \"2024-02-13\",\n \"min_delivery_date\": \"2024-02-13\",\n \"max_delivery_date\": \"2024-02-15\"\n },\n {\n \"id\": 31,\n \"carrier_service_name\": \"FedEx Home\",\n \"level\": \"GROUND_HD\",\n \"postbox_ok\": false,\n \"home_only\": true,\n \"business_only\": false,\n \"traceable\": true,\n \"transit_time\": 5,\n \"cost_excl_tax\": 11.69,\n \"currency\": \"USD\",\n \"is_active\": true,\n \"total_days_min\": 10,\n \"total_days_max\": 12,\n \"min_dispatch_date\": \"2024-02-09\",\n \"max_dispatch_date\": \"2024-02-13\",\n \"min_delivery_date\": \"2024-02-16\",\n \"max_delivery_date\": \"2024-02-20\"\n },\n {\n \"id\": 32,\n \"carrier_service_name\": \"FedEx Standard Overnight\",\n \"level\": \"EXPRESS\",\n \"postbox_ok\": false,\n \"home_only\": false,\n \"business_only\": false,\n \"traceable\": true,\n \"transit_time\": 1,\n \"cost_excl_tax\": 23.69,\n \"currency\": \"USD\",\n \"is_active\": true,\n \"total_days_min\": 6,\n \"total_days_max\": 8,\n \"min_dispatch_date\": \"2024-02-09\",\n \"max_dispatch_date\": \"2024-02-13\",\n \"min_delivery_date\": \"2024-02-12\",\n \"max_delivery_date\": \"2024-02-14\"\n },\n {\n \"id\": 34,\n \"carrier_service_name\": \"USPS Priority Mail\",\n \"level\": \"PRIORITY_MAIL\",\n \"postbox_ok\": true,\n \"home_only\": false,\n \"business_only\": false,\n \"traceable\": true,\n \"transit_time\": 5,\n \"cost_excl_tax\": 11.94,\n \"currency\": \"USD\",\n \"is_active\": true,\n \"total_days_min\": 10,\n \"total_days_max\": 12,\n \"min_dispatch_date\": \"2024-02-09\",\n \"max_dispatch_date\": \"2024-02-13\",\n \"min_delivery_date\": \"2024-02-16\",\n \"max_delivery_date\": \"2024-02-20\"\n },\n {\n \"id\": 1241,\n \"carrier_service_name\": \"UPS Mail Innovation\",\n \"level\": \"MAIL\",\n \"postbox_ok\": true,\n \"home_only\": false,\n \"business_only\": false,\n \"traceable\": true,\n \"transit_time\": 7,\n \"cost_excl_tax\": 5.69,\n \"currency\": \"USD\",\n \"is_active\": true,\n \"total_days_min\": 12,\n \"total_days_max\": 14,\n \"min_dispatch_date\": \"2024-02-09\",\n \"max_dispatch_date\": \"2024-02-13\",\n \"min_delivery_date\": \"2024-02-20\",\n \"max_delivery_date\": \"2024-02-22\"\n }\n ]\n }\n]"
},
"metadata": {
"designer": {
"x": 1984,
"y": 465,
"name": "example structure",
"messages": [
{
"category": "last",
"severity": "warning",
"message": "A transformer should not be the last module in the route."
}
]
},
"restore": {
"parameters": {
"type": {
"label": "Choose a data structure"
}
}
},
"parameters": [
{
"name": "type",
"type": "udt",
"label": "Data structure"
}
],
"expect": [
{
"name": "json",
"type": "text",
"label": "JSON string",
"required": true
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}