I'm currently trying to debug a case where json_encode fails in encoding a pretty big, multilevel array from my LDAP server. Well, its probably not that big, but it contains both numeric and non-numeric indexes, is in parts about 3 levels deep and has overall maybe around 300 elements.
However, I can't get json_last_error() to work as described in the manual: https://www.php.net/manual/de/function.json-last-error.php
I don't get any of the error codes listed there, instead only the rather cryptic response "5". I already found another stackoverflow question where someone dealt with the response "4", which was a case where json_decode threw the error: PHP json_decode return error code 4
However, I couldn't find any source on the internet where these numeric responses are resolved to any other meaningful errorcode or message, so I couldn't decipher my code yet xD
Can anyone give me a hand here?^^
EDIT: So I found out that we have a JSON_SYNTAX_ERROR thanks to nigelRen and aynber.
I checked out an online encoder to see what happens. Strange thing: The array could be encoded! I then inputted the JSON string into JSONLint to validate it and it worked! I even inputted it into an online decoder and it worked!
So why is it not working inside my program? Im using lumen (laravel 6.2) and the latest php (7.3.1ish) in the latest XAMPP environment.
EDIT2: Here is the anonymised data:
array (
'count' => 1,
0 =>
array (
'objectclass' =>
array (
'count' => 4,
0 => 'top',
1 => 'person',
2 => 'organizationalPerson',
3 => 'user',
),
0 => 'objectclass',
'cn' =>
array (
'count' => 1,
0 => 'tester',
),
1 => 'cn',
'sn' =>
array (
'count' => 1,
0 => 'testerr',
),
2 => 'sn',
'l' =>
array (
'count' => 1,
0 => 'testerrr',
),
3 => 'l',
'title' =>
array (
'count' => 1,
0 => 'testdata',
),
4 => 'title',
'description' =>
array (
'count' => 1,
0 => 'hoho',
),
5 => 'description',
'postalcode' =>
array (
'count' => 1,
0 => 'XXXXX',
),
6 => 'postalcode',
'physicaldeliveryofficename' =>
array (
'count' => 1,
0 => 'korr',
),
7 => 'physicaldeliveryofficename',
'telephonenumber' =>
array (
'count' => 1,
0 => 'numberex',
),
8 => 'telephonenumber',
'facsimiletelephonenumber' =>
array (
'count' => 1,
0 => 'yarrr',
),
9 => 'facsimiletelephonenumber',
'givenname' =>
array (
'count' => 1,
0 => 'test',
),
10 => 'givenname',
'initials' =>
array (
'count' => 1,
0 => 'testtttt',
),
11 => 'initials',
'distinguishedname' =>
array (
'count' => 1,
0 => 'CN=fr,OU=Benutzer,OU=ent,DC=entt,DC=us',
),
12 => 'distinguishedname',
'instancetype' =>
array (
'count' => 1,
0 => '4',
),
13 => 'instancetype',
'whencreated' =>
array (
'count' => 1,
0 => '20920828125555.0Z',
),
14 => 'whencreated',
'whenchanged' =>
array (
'count' => 1,
0 => '20931216110629.0Z',
),
15 => 'whenchanged',
'displayname' =>
array (
'count' => 1,
0 => 'tester test',
),
16 => 'displayname',
'usncreated' =>
array (
'count' => 1,
0 => '29778728',
),
17 => 'usncreated',
'info' =>
array (
'count' => 1,
0 => 'testererer',
),
18 => 'info',
'memberof' =>
array (
'count' => 12,
0 => 'CN=döjfsdkmf,OU=Gruppen,OU=testent,DC=testent,DC=asdsad',
1 => 'CN=ösmfsmfosmf,OU=Variabel,OU=Verteiler,OU=testent,DC=testent,DC=asdsad',
2 => 'CN=sdkfnsfm (Standort),OU=Orga,OU=Verteiler,OU=testent,DC=testent,DC=asdsad',
3 => 'CN=skfdjnsdkfm,OU=sdfsdfsdf,OU=OEs,OU=Gruppen,OU=testent,DC=testent,DC=asdsad',
4 => 'CN=sdfsdofmsdf,CN=Users,DC=testent,DC=asdsad',
5 => 'CN=sdfjknsfkmsdf,OU=Alte_Gruppen,OU=Gruppen,OU=testent,DC=testent,DC=asdsad',
6 => 'CN=sfsdfsdfsdf,CN=Users,DC=testent,DC=asdsad',
7 => 'CN=sdfsdfsdfsdfsdf,OU=Alte_Gruppen,OU=Gruppen,OU=testent,DC=testent,DC=asdsad',
8 => 'CN=sdfsdfsdfsdf,CN=Users,DC=testent,DC=asdsad',
9 => 'CN=weöfjsiofdjshfdjhsfd,CN=Users,DC=testent,DC=asdsad',
10 => 'CN=sfnsifnsf,OU=Alte_Gruppen,OU=Gruppen,OU=testent,DC=testent,DC=asdsad',
11 => 'CN=skfunsifnsifnsf,CN=Users,DC=testent,DC=asdsad',
),
19 => 'memberof',
'usnchanged' =>
array (
'count' => 1,
0 => '54730333',
),
20 => 'usnchanged',
'company' =>
array (
'count' => 1,
0 => 'testent AG',
),
21 => 'company',
'proxyaddresses' =>
array (
'count' => 4,
0 => 'smtp:testent2@irene.testent.asdsad',
1 => 'SMTP:testent23.41wdsadsad@testent.asdsad',
2 => 'smtp:testent2@testent.asdsad',
3 => 'smtp:testent2@iris.testent.asdsad',
),
22 => 'proxyaddresses',
'streetaddress' =>
array (
'count' => 1,
0 => 'Kleinseebacher Str. 9',
),
23 => 'streetaddress',
'displaynameprintable' =>
array (
'count' => 1,
0 => 'testent23 41wdsadsad',
),
24 => 'displaynameprintable',
'name' =>
array (
'count' => 1,
0 => 'testent2',
),
25 => 'name',
'objectguid' =>
array (
'count' => 1,
0 => '��tk���G�A�4�=�\\',
),
26 => 'objectguid',
'useraccountcontrol' =>
array (
'count' => 1,
0 => '66048',
),
27 => 'useraccountcontrol',
'badpwdcount' =>
array (
'count' => 1,
0 => '0',
),
28 => 'badpwdcount',
'codepage' =>
array (
'count' => 1,
0 => '0',
),
29 => 'codepage',
'countrycode' =>
array (
'count' => 1,
0 => '0',
),
30 => 'countrycode',
'badpasswordtime' =>
array (
'count' => 1,
0 => '132212342228691135',
),
31 => 'badpasswordtime',
'lastlogoff' =>
array (
'count' => 1,
0 => '0',
),
32 => 'lastlogoff',
'lastlogon' =>
array (
'count' => 1,
0 => '132212399056122426',
),
33 => 'lastlogon',
'pwdlastset' =>
array (
'count' => 1,
0 => '131921875059860861',
),
34 => 'pwdlastset',
'primarygroupid' =>
array (
'count' => 1,
0 => 'sdgght2',
),
35 => 'primarygroupid',
'profilepath' =>
array (
'count' => 1,
0 => '\\\\sdfsdfsdf\\users\\testent2\\_win_profil',
),
36 => 'profilepath',
'objectsid' =>
array (
'count' => 1,
0 => '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '�s� ��w�o� "' . "\0" . '' . "\0" . '',
),
37 => 'objectsid',
'accountexpires' =>
array (
'count' => 1,
0 => '9223372036854775807',
),
38 => 'accountexpires',
'logoncount' =>
array (
'count' => 1,
0 => '4515',
),
39 => 'logoncount',
'samaccountname' =>
array (
'count' => 1,
0 => 'testent2',
),
40 => 'samaccountname',
'samaccounttype' =>
array (
'count' => 1,
0 => '805306368',
),
41 => 'samaccounttype',
'showinaddressbook' =>
array (
'count' => 5,
0 => 'CN=Mailboxes(VLV),CN=dfgfdgfdg,CN=Address Lists Container,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=asdsad',
1 => 'CN=All Mailboxes(VLV),CN=dfgfdgfdg,CN=Address Lists Container,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=asdsad',
2 => 'CN=All Recipients(VLV),CN=dfgfdgfdg,CN=Address Lists Container,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=asdsad',
3 => 'CN=Alle Benutzer,CN=dfgfdgfdg,CN=Address Lists Container,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=asdsad',
4 => 'CN=Globale Standardadressliste,CN=All Global Address Lists,CN=Address Lists Container,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=asdsad',
),
42 => 'showinaddressbook',
'managedobjects' =>
array (
'count' => 1,
0 => 'CN=JUVENTAS,CN=Computers,DC=testent,DC=asdsad',
),
43 => 'managedobjects',
'legacyexchangedn' =>
array (
'count' => 1,
0 => '/o=testent/ou=Exchange Administrative Group (sfsdfsdf)/cn=Recipients/cn=testent23 41wdsadsad071',
),
44 => 'legacyexchangedn',
'userprincipalname' =>
array (
'count' => 1,
0 => 'testent2@testent.asdsad',
),
45 => 'userprincipalname',
'lockouttime' =>
array (
'count' => 1,
0 => '0',
),
46 => 'lockouttime',
'objectcategory' =>
array (
'count' => 1,
0 => 'CN=Person,CN=Schema,CN=Configuration,DC=testent,DC=asdsad',
),
47 => 'objectcategory',
'dscorepropagationdata' =>
array (
'count' => 5,
0 => '20901211120329.0Z',
1 => '20901211120329.0Z',
2 => '20901211120329.0Z',
3 => '20901211120329.0Z',
4 => '20901211120329.0Z',
),
48 => 'dscorepropagationdata',
'ms-ds-consistencyguid' =>
array (
'count' => 1,
0 => '��tk���G�A�4�=�\\',
),
49 => 'ms-ds-consistencyguid',
'lastlogontimestamp' =>
array (
'count' => 1,
0 => '132209679579424599',
),
50 => 'lastlogontimestamp',
'mail' =>
array (
'count' => 1,
0 => 'testent23.41wdsadsad@testent.asdsad',
),
51 => 'mail',
'msexchmailboxtemplatelink' =>
array (
'count' => 1,
0 => 'CN=testentRetentionPolicy,CN=Retention Policies Container,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=asdsad',
),
52 => 'msexchmailboxtemplatelink',
'msexchumdtmfmap' =>
array (
'count' => 5,
0 => 'reversedPhone:sdfsdfsf',
1 => 'reversedPhone:sdaqwdqdq',
2 => 'emailAddress:asdsadwqdw',
3 => 'lastNameFirstName:asdasdsad',
4 => 'firstNameLastName:sadsadsad',
),
53 => 'msexchumdtmfmap',
'msexchblockedsendershash' =>
array (
'count' => 1,
0 => 'W�G�x.�',
),
54 => 'msexchblockedsendershash',
'msexchmailboxsecuritydescriptor' =>
array (
'count' => 1,
0 => '' . "\0" . '�' . "\0" . '' . "\0" . '' . "\0" . ' ' . "\0" . '' . "\0" . '' . "\0" . ',' . "\0" . '' . "\0" . '' . "\0" . '\\' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '
' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '
' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '0' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '�' . "\0" . '' . "\0" . '
' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '�' . "\0" . 'k
' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '
' . "\0" . '' . "\0" . '' . "\0" . '',
),
55 => 'msexchmailboxsecuritydescriptor',
'mdbusedefaults' =>
array (
'count' => 1,
0 => 'TRUE',
),
56 => 'mdbusedefaults',
'msexchpoliciesexcluded' =>
array (
'count' => 1,
0 => '{har-har}',
),
57 => 'msexchpoliciesexcluded',
'mailnickname' =>
array (
'count' => 1,
0 => 'testent2',
),
58 => 'mailnickname',
'msexchshadowmailnickname' =>
array (
'count' => 1,
0 => 'testent2',
),
59 => 'msexchshadowmailnickname',
'msexchversion' =>
array (
'count' => 1,
0 => 'sdad',
),
60 => 'msexchversion',
'msexchuserculture' =>
array (
'count' => 1,
0 => 'us-US',
),
61 => 'msexchuserculture',
'msexchthrottlingpolicydn' =>
array (
'count' => 1,
0 => 'CN=fgdgg,CN=Global Settings,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=us',
),
62 => 'msexchthrottlingpolicydn',
'msexchmailboxguid' =>
array (
'count' => 1,
0 => '���e��[F��N��@',
),
63 => 'msexchmailboxguid',
'msexchrecipienttypedetails' =>
array (
'count' => 1,
0 => '1',
),
64 => 'msexchrecipienttypedetails',
'msexchuseraccountcontrol' =>
array (
'count' => 1,
0 => '0',
),
65 => 'msexchuseraccountcontrol',
'homemdb' =>
array (
'count' => 1,
0 => 'CN=Mailbox-DB_testent-A,CN=Databases,CN=sdfsdfsdf (dgdfgfdgdfg),CN=Administrative Groups,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=us',
),
66 => 'homemdb',
'msexchhomeservername' =>
array (
'count' => 1,
0 => '/o=testent/ou=fsfdf sfdsdfsdf sdfsfd (sadadwd)/cn=Configuration/cn=Servers/cn=KIREI',
),
67 => 'msexchhomeservername',
'msexchaddressbookpolicylink' =>
array (
'count' => 1,
0 => 'CN=testentAddressBookPolicy-2016,CN=AddressBook Mailbox Policies,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=us',
),
68 => 'msexchaddressbookpolicylink',
'msexchtextmessagingstate' =>
array (
'count' => 2,
0 => 'asdsadsad',
1 => 'sadsadadw',
),
69 => 'msexchtextmessagingstate',
'msexchsafesendershash' =>
array (
'count' => 1,
0 => '�01
~' . "\0" . ';:�FhR��t�{�E����{�7��"pA�\\���v�X�ޕa�d ��',
),
70 => 'msexchsafesendershash',
'msexchmailboxmovesourceuserbl' =>
array (
'count' => 1,
0 => 'CN=bc27209faf284aac937204a02ccee4b0testent2-testent2_20191215214915,CN=MailboxExportRequests,CN=Mailbox Replication,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=asdsad',
),
71 => 'msexchmailboxmovesourceuserbl',
'msexchshadowproxyaddresses' =>
array (
'count' => 3,
0 => 'SMTP:testent23.41wdsadsad@testent.asdsad',
1 => 'smtp:testent2@testent.asdsad',
2 => 'smtp:testent2@sdwdqd.testent.asdsad',
),
72 => 'msexchshadowproxyaddresses',
'msexchelcmailboxflags' =>
array (
'count' => 1,
0 => '2',
),
73 => 'msexchelcmailboxflags',
'msexchrbacpolicylink' =>
array (
'count' => 1,
0 => 'CN=Default Role Assignment Policy,CN=Policies,CN=RBAC,CN=testent,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testent,DC=us',
),
74 => 'msexchrbacpolicylink',
'msexchwhenmailboxcreated' =>
array (
'count' => 1,
0 => '20980829074612.0Z',
),
75 => 'msexchwhenmailboxcreated',
'msexchrecipientdisplaytype' =>
array (
'count' => 1,
0 => 'sadsadad',
),
76 => 'msexchrecipientdisplaytype',
'count' => 77,
'dn' => 'CN=testent2,OU=Benutzer,OU=testent,DC=testent,DC=us',
),
)