How to use JSONPath for freight data mapping without losing records
Declare how many matching nodes a mapping expects. No match is not a JSON null, and multiple matches must not silently become the first value. When a list is intentional, keep each value linked to the shipment or stop it came from.
The query locates nodes; the business rule decides what is acceptable.
RFC 9535 defines JSONPath queries and their results as node lists. Use syntax supported by the agreed profile. Define expected cardinality, value type and the scope of the record outside the query. Record a safe indication of the selected location for error review without disclosing unrelated shipment data.
A selector finds two delivery references for a single-value field.
A synthetic payload contains two delivery stops. A selector finds a reference on each, but the receiving field expects one. Do not select the first as a default. Either use a confirmed stop identifier to select the intended record or report the mismatch. If the receiver supports a list, map each reference with its stop.
Check empty matches, null and multiple matches explicitly.
- Test a missing property, a null value and two matching nodes as distinct cases.
- Check reordered arrays without relying on position as a business identifier.
- Compare the expected selection across implementations and test the partner’s business rules independently.