JPath Surgery
The marketplace your company sells through pushes one consolidated order feed: a nested JSON document of orders, order lines, and shipments whose packages nest inside each other whenever the carrier consolidates parcels. The operations dashboard needs a handful of precise answers out of that document, and the previous attempt — a wall of nested foreach loops — died the day a consolidation nested one level deeper than the sample payload. You are replacing it with a digest that asks the document exact questions and shrugs off whatever it cannot find.
The feed
Every payload is one syntactically valid JSON object shaped like this:
{
"feedId": "F-2026-0718",
"orders": [
{
"orderNo": "SO-1001",
"total": 349.5,
"customer": { "name": "Northwind Traders", "vip": true, "contact": { "email": "po@northwind.example" } },
"lines": [
{ "sku": "KB-2049", "qty": 2, "amount": 149.5, "status": "open" },
{ "sku": "MS-0110", "qty": 1, "amount": 200, "status": "shipped" }
],
"shipment": {
"carrier": "DHL",
"packages": [
{ "tracking": "JD014600003582", "packages": [ { "tracking": "JD014600003583" } ] }
]
}
}
]
}Shape rules — every grading feed honors them:
feedIdand theordersarray are always present;ordersmay be empty.- An order always has
orderNo(a string);total(a number),customer,lines, andshipmentmay each be absent. - A
customeralways hasname;vip(a JSON boolean) andcontactmay be absent, and acontactmay or may not carry anemailstring. - A line always has
sku,amount(a number), andstatus— andstatusis exactly one ofopen,shipped, orcancelled, lowercase.
Solve it with Pro
You’re reading the opening of the statement. Pro unlocks the whole problem:
- The full statement
- Starter code in the browser editor
- 16 grading tests, run on Business Central 28.5
- 3 hints
- The reference solution
Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.
Already on Pro? Sign in