0

I am using the LinkedIn API and it gives me a similar result to the following: $data = json_decode($response);

I need access to "organization~" but I can´t. ¿How I can access element object when exist this character? I using PHP.

{
  "elements": [
    {
      "organization~": {
        "localizedName": "TestCompany"
      },
      "role": "ADMINISTRATOR",
      "roleAssignee": "urn:li:person:pE3vIq7yK6",
      "state": "APPROVED",
      "roleAssignee~": {
        "localizedLastName": "Smith",
        "localizedFirstName": "John"
      },
      "organization": "urn:li:organization:18062654"
    }
    {
      "organization~": {
        "localizedName": "TestCompanyShowcase"
      },
      "role": "ADMINISTRATOR",
      "roleAssignee": "urn:li:person:pE3vIq7yK6",
      "state": "APPROVED",
      "roleAssignee~": {
        "localizedLastName": "Smith",
        "localizedFirstName": "John"
      },
      "organization": "urn:li:organizationBrand:18085185"
    },
    {
      "organization~": {
        "localizedName": "DevTestCo \"Quote\""
      },
      "role": "ADMINISTRATOR",
      "roleAssignee": "urn:li:person:pE3vIq7yK6",
      "state": "APPROVED",
      "roleAssignee~": {
        "localizedLastName": "Smith",
        "localizedFirstName": "John"
      },
      "organization": "urn:li:organization:2414183"
    }
  ]
}
Neftali Acosta
  • 418
  • 4
  • 15
  • Does this answer your question? [Special characters in property name of object](https://stackoverflow.com/questions/10455775/special-characters-in-property-name-of-object) – catcon Aug 09 '21 at 04:45
  • Or you can parse the JSON to an array instead of an object i.e: `json_decode($response, true)` and then access the item like this `$data['elements'][0]['organization~'];` – catcon Aug 09 '21 at 04:50

1 Answers1

0

echo $myobject->{'%myproperty'};

Neftali Acosta
  • 418
  • 4
  • 15