title: How to extract data inside JSON response from Zoho CRM API
body: <p>I'm working with the Zoho CRM. The response format I get from their API seems a bit odd to me; I can't just pull an object from it like I would normally. I'm trying to parse the results using PHP. Here's an example of their response formatting:</p>
  
  <pre><code>{
      "response": {
          "result": {
              "SalesOrders": {
                  "row": {
                      "FL": [
                          {
                              "content": "6666666000000000000",
                              "val": "SALESORDERID"
                          },
                          {
                              "content": "Order",
                              "val": "Subject"
                          },
                          {
                              "content": "Pending",
                              "val": "Status"
                          },
                          {
                              "content": "John Smith",
                              "val": "Order Owner"
                          },
                          {
                              "content": "Canada",
                              "val": "Billing Country"
                          },
                          {
                              "product": {
                                  "FL": [
                                      {
                                          "content": "5555555000000000000",
                                          "val": "Product Id"
                                      },
                                      {
                                          "content": "Roller Coaster",
                                          "val": "Product Name"
                                      }
                                  ],
                                  "no": "1"
                              },
                              "val": "Product Details"
                          },
                              "content": "Pending",
                              "val": "Ticket Status"
                          }
                      ],
                      "no": "1"
                  }
              }
          },
          "uri": "/crm/private/json/SalesOrders/getRecordById"
      }
  }
  </code></pre>
  
  <p>What I'm trying to do is get the Product ID of the Product (in this case the value is "5555555000000000000".</p>
  
  <p>Every response has the same structure, but I can't use the index to parse out the key/value because the amount of fields could change between API calls (meaning the index of product could be 5, like above, or 7, or 8, or whatever depending on the amount of fields being pulled in). I don't understand why they didn't use typical key/value pairs, such as "Product_ID": "5555555000000000000" which would make all of this a non-issue.</p>
  
  <p>Is there a way to do this without iterating through every key/value pair looking for a "val" of "Product ID" and then grabbing the associated "content" (which is the product id I'm looking for)? That's the only way I could think of and it doesn't seem very efficient.</p>