5051

JPath Surgery

Integrations
Medium
Pro
json
jsonpath
api
parsing

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:

  • feedId and the orders array are always present; orders may be empty.
  • An order always has orderNo (a string); total (a number), customer, lines, and shipment may each be absent.
  • A customer always has name; vip (a JSON boolean) and contact may be absent, and a contact may or may not carry an email string.
  • A line always has sku, amount (a number), and status — and status is exactly one of open, shipped, or cancelled, lowercase.
The rest of the statement and 3 hints Unlock with Pro
ALBusiness Central 28.5
Pro
Pro problem

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.

$10 / month
or $100 / year
Upgrade
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade