# How can I capture the products from a shopping cart if it has 2 or more products selected, from the json with grail

**URL:** <https://community.dynatrace.com/t/how-can-i-capture-the-products-from-a-shopping-cart-if-it-has-2-or-more-products-selected-from-the-json-with-grail/44985>\
**Category:** DQL\
**Tags:** dql, json\
**Created:** [April 3, 2024, 7:54pm UTC](https://community.dynatrace.com/t/how-can-i-capture-the-products-from-a-shopping-cart-if-it-has-2-or-more-products-selected-from-the-json-with-grail/44985 "2024-04-03T19:54:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dff](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@dff](https://community.dynatrace.com/u/dff)\
**Post date:** [April 3, 2024, 7:54pm UTC](https://community.dynatrace.com/t/how-can-i-capture-the-products-from-a-shopping-cart-if-it-has-2-or-more-products-selected-from-the-json-with-grail/44985/1 "2024-04-03T19:54:25Z")

</div>

Hello, I have a concern.

I have the following Quuery. Which the product field brings in json, but separating it only allows me from the first block only

The idea is that I separate them into 2 or 3 results depending on the number of products that the json brings

attached query

fetch bizevents , from:now()-1h, to:now()  
| filter event.type==“[portalcmo.fyags.com/wpcmo](http://portalcmo.fyags.com/wpcmo)”  
| filter orderNumber==“2660”  
| parse productos, “DATA json:json”  
| fieldsAdd nombre = json[nombre], cantidad = json[cantidad], precio\_unitario = json[precio\_unitario] ,totalPedido,orderNumber  
| fields productos,nombre, orderNumber

 ![dff_0-1712173704777.png](https://global.discourse-cdn.com/dynatrace/original/2X/f/fbf73dae256149e418cee52f6d7b287e624f17b6.png)

The idea is:

which the 2 products correspond to the same order  
nombre&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Order&nbsp;  
Product1&nbsp; &nbsp; &nbsp; &nbsp;1234

product2&nbsp; &nbsp; &nbsp; 1234

---

<div class="post-metadata">

**Author:** ![cesarsaravia](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/cesarsaravia/32/12818_2.png) [@cesarsaravia](https://community.dynatrace.com/u/cesarsaravia)\
**Post date:** [April 3, 2024, 8:30pm UTC](https://community.dynatrace.com/t/how-can-i-capture-the-products-from-a-shopping-cart-if-it-has-2-or-more-products-selected-from-the-json-with-grail/44985/2 "2024-04-03T20:30:29Z")

</div>

Hi&nbsp;[@dff](https://community.dynatrace.com/user/61528)

You must have to use JSON\_ARRAY instead of JSON, and then expand the rows.

```markup
data record(productos="""[
    {
      "nombre": "Basic Blue Jeans",
      "cantidad": 2,
      "precio_unitario": 30
    },
    {
      "nombre": "DNK Purple tshirt",
      "cantidad": 3,
      "precio_unitario": 45
    }
  ]""",orderNumber="2660", totalPedido=1500)
| filter orderNumber=="2660"
| parse productos,"JSON_ARRAY:json"
| expand json
| fieldsAdd nombre = json[nombre], cantidad = json[cantidad], precio_unitario = json[precio_unitario] ,totalPedido,orderNumber
| fields productos,nombre, orderNumber, totalPedido, cantidad, precio_unitario

```

Example:

 ![cesarsaravia_0-1712176169210.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/b/9b51f38c037c1684862ca50336c1b67da972964e.png)
