dimanche 12 juillet 2020

Laravel Get Json Array from Post request

I'm building an api for eCommerce app

and i have Post request where the user post some data in json

JSON Request

    [
   {
         "shop_id":1,
      "items":[
         {
            "product_id":2,
            "price":4.75,
            "quantity":1
         },
         {
            "product_id":6,
            "price":18.5,
            "quantity":1
         },
         {
            "product_id":10,
            "price":88,
            "quantity":2
         }
      ]
   }
]

Now, I know how to get the whole Json from $request by using getContent() but, what if i just need to get an array of objects

For Example:

How to get the Content of Items Array ?

Any Ideas??



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire