How can i get the key in JSON representation with JMSerializerBundle ?

21 views
Skip to first unread message

Roberto Jesús Rielo Villadóniga

unread,
Oct 8, 2015, 1:41:31 AM10/8/15
to Guzzle - PHP HTTP client and REST client framework
First of all sorry because my english is not the best.

Im working with Misd-Guzzle Bundle and JMSerializer but I dont know how to solve this problem.
The point is that i need to parse the response im getting when i send a request to the API.

I have this:
"GetAddresses": {
"httpMethod": "GET",
"uri": "/tads",
"summary": "Returns all the addresses registered in API",
"responseClass": "array<AppBundle\\Entity\\Address>"
}

However the API returns this:
  1. {
  2.    "_links":
  3.    {
  4.        "self":
  5.        {
  6.            "href": "http://api.hscode09bids.com/tads?page=1"
  7.        },
  8.        "first":
  9.        {
  10.            "href": "http://api.hscode09bids.com/tads"
  11.        },
  12.        "last":
  13.        {
  14.            "href": "http://api.hscode09bids.com/tads?page=1"
  15.        }
  16.    },
  17.    "_embedded":
  18.    {
  19.        "tads":
  20.        [
  21.            {
  22.                "id": "1",
  23.                "adsName": "Street",
  24.                "adsCity": "Havana",
  25.                "adsState": "Arroyo",
  26.                "adsZipCode": "10400",
  27.                "adsCtyId": "1"
  28.             },
  29.            {
  30.                "id": "0",
  31.                "adsName": "Street2",
  32.                "adsCity": "Havana2",
  33.                "adsState": "Arroyo2",
  34.                "adsZipCode": "10401",
  35.                "adsCtyId": "2"               
  36.            },
  37.            {
  38.                "id": "2",
  39.                "adsName": "Street3",
  40.                "adsCity": "Havana3",
  41.                "adsState": "Arroyo3",
  42.                "adsZipCode": "10403",
  43.                "adsCtyId": "3"                
  44.            }
  45.        ]
  46.    },
  47.    "page_count": 1,
  48.    "page_size": 25,
  49.    "total_items": 5
  50. }
How can i say to my entity Address that the element to take into account is "tads" and not the complete response.
Or maybe parse this response for making "tads" array value the response I need.
I'd really appreciate your help.

Reply all
Reply to author
Forward
0 new messages