In this example, zoom retrieved the cart
resource and its corresponding lineitems and total
resources. Once the client application receives the response, JSONPath can extract the data
you're interested in.
- {
- "self": {
- "type": "elasticpath.carts.cart",
- "uri": "/commerce-legacy/carts/mobee/guz=?zoom=lineitems,total",
- "href": "http://api.elasticpath.net/cortex/carts/mobee/guz=?zoom=lineitems,total"
- },
- "total-quantity": 3,
- "links": [
- {
- "rel": "lineitems",
- "rev": "cart",
- "type": "elasticpath.collections.links",
- "uri": "/commerce-legacy/carts/mobee/guz=/lineitems",
- "href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems"
- },
- {
- "rel": "order",
- "rev": "cart",
- "type": "elasticpath.orders.order",
- "uri": "/commerce-legacy/orders/mobee/mu3=",
- "href": "http://api.elasticpath.net/cortex/orders/mobee/mu3="
- },
- {
- "rel": "total",
- "rev": "cart",
- "type": "elasticpath.totals.total",
- "uri": "/commerce-legacy/totals/carts/mobee/guz=",
- "href": "http://api.elasticpath.net/cortex/totals/carts/mobee/guz="
-
- }
- ],
-
- "_lineitems": [
- {
- "self": {
- "type": "elasticpath.collections.links",
- "uri": "/commerce-legacy/carts/mobee/guz=/lineitems",
- "href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems"
- },
- "links": [
- {
- "rel": "element",
- "rev": "list",
- "type": "elasticpath.carts.line-item",
- "uri": "/commerce-legacy/carts/mobee/guz=/lineitems/hfq=",
- "href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems/hfq="
- },
- {
- "rel": "element",
- "rev": "list",
- "type": "elasticpath.carts.line-item",
- "uri": "/commerce-legacy/carts/mobee/guz=/lineitems/gbq=",
- "href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems/gbq="
- },
- {
- "rel": "cart",
- "rev": "lineitems",
- "type": "elasticpath.carts.cart",
- "uri": "/commerce-legacy/carts/mobee/guz=",
- "href": "http://api.elasticpath.net/cortex/carts/mobee/guz="
- }
- ]
- }
- ],
- "_total": [
- {
- "self": {
- "type": "elasticpath.totals.total",
- "uri": "/commerce-legacy/totals/carts/mobee/guz=",
- "href": "http://api.elasticpath.net/cortex/totals/carts/mobee/guz="
- },
- "cost": [
- {
- "amount": 211,
- "currency": "CAD",
- "display": "$211.00"
- }
- ],
- "links": [
- {
- "rel": "cart",
- "rev": "total",
- "type": "elasticpath.carts.cart",
- "uri": "/commerce-legacy/carts/mobee/guz=",
- "href": "http://api.elasticpath.net/cortex/carts/mobee/guz="
- }
- ]
- }
- ]
-
- }
Copy
...
Read moreRead less
Table 1. JSONPath Examples
Example |
JSONPath |
Result |
---|
Extract the total-quantity child property. |
- $total-quantity
Copy | - [
- 3
- ]
Copy |
Extract every quantity value nested in other properties. | - $..quantity
Copy | - [
- 2,
- 1
- ]
Copy |
Extract the first element of the total cost array. | - $_total..cost[0]
Copy | - [
- {
- "amount": 211,
- "currency": "CAD",
- "display": "$211.00"
- }
- ]
Copy |