Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Considering you have <a href="http://www.php.net/json_decode" rel="noreferrer"><code>json_decode</code></a>d you data this way :</p> <pre><code>$data = json_decode($json); </code></pre> <p>You can use <a href="http://www.php.net/var_dump" rel="noreferrer"><code>var_dump</code></a> <em>(well, it's output looks way better if used with the <a href="http://xdebug.org/" rel="noreferrer">Xdebug</a> extension, which is nice to have on a development machine, btw)</em> to know what's in your data :</p> <pre><code>// Allows you to know what's in the data ;-) var_dump($data); </code></pre> <p>You'll get something like this :</p> <pre><code>object(stdClass)[1] public 'communications' =&gt; object(stdClass)[2] public 'communication' =&gt; array 0 =&gt; object(stdClass)[3] public '@array' =&gt; string 'true' (length=4) public '@id' =&gt; string '23101384' (length=8) public '@uri' =&gt; string 'xyz/v1/Communications/1111' (length=26) public 'household' =&gt; object(stdClass)[4] public '@id' =&gt; string '111111' (length=6) public '@uri' =&gt; string 'xyz/v1/Households/5465465' (length=25) public 'person' =&gt; object(stdClass)[5] public '@id' =&gt; string '' (length=0) public '@uri' =&gt; string '' (length=0) public 'communicationType' =&gt; object(stdClass)[6] public '@id' =&gt; string '1' (length=1) public '@uri' =&gt; string 'xyz/v1/Communications/CommunicationTypes/1' (length=42) public 'name' =&gt; string 'Home Phone' (length=10) public 'communicationGeneralType' =&gt; string 'Telephone' (length=9) public 'communicationValue' =&gt; string '1111' (length=4) public 'searchCommunicationValue' =&gt; string '2693240758' (length=10) public 'listed' =&gt; string 'true' (length=4) public 'communicationComment' =&gt; null public 'createdDate' =&gt; string '2008-11-10T12:31:26' (length=19) public 'lastUpdatedDate' =&gt; string '2009-08-11T23:40:02' (length=19) 1 =&gt; object(stdClass)[7] public '@array' =&gt; string 'true' (length=4) public '@id' =&gt; string '11111' (length=5) public '@uri' =&gt; string 'xyz/v1/Communications/111111111' (length=31) public 'household' =&gt; object(stdClass)[8] public '@id' =&gt; string '14436295' (length=8) public '@uri' =&gt; string 'xyz/v1/Households/11111' (length=23) public 'person' =&gt; object(stdClass)[9] public '@id' =&gt; string '2222222' (length=7) public '@uri' =&gt; string 'xyz/v1/People/22222222' (length=22) public 'communicationType' =&gt; object(stdClass)[10] public '@id' =&gt; string '2' (length=1) public '@uri' =&gt; string 'xyz/v1/Communications/CommunicationTypes/2' (length=42) public 'name' =&gt; string 'Work Phone' (length=10) public 'communicationGeneralType' =&gt; string 'Telephone' (length=9) public 'communicationValue' =&gt; string '11111' (length=5) public 'searchCommunicationValue' =&gt; string '789787987' (length=9) public 'listed' =&gt; string 'false' (length=5) public 'communicationComment' =&gt; null public 'createdDate' =&gt; string '2009-08-09T15:49:27' (length=19) public 'lastUpdatedDate' =&gt; string '2009-08-11T23:40:02' (length=19) 2 =&gt; object(stdClass)[11] public '@array' =&gt; string 'true' (length=4) public '@id' =&gt; string '11111' (length=5) public '@uri' =&gt; string 'xyz/v1/Communications/11111' (length=27) public 'household' =&gt; object(stdClass)[12] public '@id' =&gt; string '1111' (length=4) public '@uri' =&gt; string 'xyz/v1/Households/1111' (length=22) public 'person' =&gt; object(stdClass)[13] public '@id' =&gt; string '244404' (length=6) public '@uri' =&gt; string 'xyz/v1/People/1111' (length=18) public 'communicationType' =&gt; object(stdClass)[14] public '@id' =&gt; string '3' (length=1) public '@uri' =&gt; string 'xyz/v1/Communications/CommunicationTypes/3' (length=42) public 'name' =&gt; string 'Mobile' (length=6) public 'communicationGeneralType' =&gt; string 'Telephone' (length=9) public 'communicationValue' =&gt; string '22222' (length=5) public 'searchCommunicationValue' =&gt; string '5475454' (length=7) public 'listed' =&gt; string 'true' (length=4) public 'communicationComment' =&gt; null public 'createdDate' =&gt; string '2008-11-10T12:31:26' (length=19) public 'lastUpdatedDate' =&gt; string '2009-08-11T23:40:02' (length=19) 3 =&gt; object(stdClass)[15] public '@array' =&gt; string 'true' (length=4) public '@id' =&gt; string '15454' (length=5) public '@uri' =&gt; string 'xyz/v1/Communications/111111' (length=28) public 'household' =&gt; object(stdClass)[16] public '@id' =&gt; string '14436295' (length=8) public '@uri' =&gt; string 'xyz/v1/Households/1111' (length=22) public 'person' =&gt; object(stdClass)[17] public '@id' =&gt; string '244444474' (length=9) public '@uri' =&gt; string 'xyz/v1/People/111111' (length=20) public 'communicationType' =&gt; object(stdClass)[18] public '@id' =&gt; string '4' (length=1) public '@uri' =&gt; string 'xyz/v1/Communications/CommunicationTypes/4' (length=42) public 'name' =&gt; string 'Email' (length=5) public 'communicationGeneralType' =&gt; string 'Email' (length=5) public 'communicationValue' =&gt; string 'email@needthis.com' (length=18) public 'searchCommunicationValue' =&gt; string 'email@needthis.com' (length=18) public 'listed' =&gt; string 'true' (length=4) public 'communicationComment' =&gt; null public 'createdDate' =&gt; string '2008-11-10T12:31:26' (length=19) public 'lastUpdatedDate' =&gt; string '2009-08-11T23:39:06' (length=19) </code></pre> <p>Which means you should be able to access the data you're looking for with something like this :</p> <pre><code>foreach ($data-&gt;communications-&gt;communication as $communication) { if ($communication-&gt;communicationGeneralType == 'Email') { var_dump($communication-&gt;communicationValue); var_dump($communication-&gt;searchCommunicationValue); } } </code></pre> <p>Which will get you :</p> <pre><code>string 'email@needthis.com' (length=18) string 'email@needthis.com' (length=18) </code></pre> <p>"<code>communications</code>" is an object, that contains "<code>communication</code>", which is an array of objects, each one containing a <code>communicationGeneralType</code>, which allows you to determine whether the current communication is an EMail or not.</p> <p>WHen it is, you can use the <code>communicationValue</code> or <code>searchCommunicationValue</code> fields.</p> <p>And I don't really see a way of doing this without iterating over every <code>communication</code> element...</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload