PHP中json_encode()返回的神秘错误代码
我目前正在尝试调试一个案例,其中json_encode无法从我的LDAP服务器编码一个相当大的多级数组。嗯,它可能没有那么大,但它同时包含数字和非数字索引,部分深度约为3级,总共大约有300个元素 但是,我无法让json_last_error()按照手册中的说明工作: 我没有得到这里列出的任何错误代码,只有相当隐晦的响应“5”。 我已经发现了另一个stackoverflow问题,其中有人处理了响应“4”,即json_decode抛出错误的情况: 然而,我在互联网上找不到任何来源,这些数字响应被解析为任何其他有意义的错误代码或消息,因此我还无法破译我的代码xD 有人能帮我一下吗^^ 编辑: 所以我发现我们有一个JSON_语法_错误,多亏了nigelRen和aynber 我检查了一个在线编码器,看看会发生什么。奇怪的是: 数组可以被编码! 然后我将JSON字符串输入到JSONLint中进行验证,结果成功了! 我甚至把它输入了一个在线解码器,它工作了 那么为什么它在我的程序中不起作用呢? Im在最新的XAMPP环境中使用lumen(Laravel6.2)和最新的php(7.3.1ish) 编辑2: 以下是匿名数据:PHP中json_encode()返回的神秘错误代码,php,json,ldap,Php,Json,Ldap,我目前正在尝试调试一个案例,其中json_encode无法从我的LDAP服务器编码一个相当大的多级数组。嗯,它可能没有那么大,但它同时包含数字和非数字索引,部分深度约为3级,总共大约有300个元素 但是,我无法让json_last_error()按照手册中的说明工作: 我没有得到这里列出的任何错误代码,只有相当隐晦的响应“5”。 我已经发现了另一个stackoverflow问题,其中有人处理了响应“4”,即json_decode抛出错误的情况: 然而,我在互联网上找不到任何来源,这些数字响应
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',
),
)
-另外,如果从0开始计算列表中的错误,您将看到JSON\u ERROR\u UTF8No,数字没有改变。查看它在哪里为不同版本的编号提供代码。在没有看到数据的情况下也匹配,我们无法判断。您确定在验证时没有未复制的隐藏字符吗?其中一些是奇数字符(例如
0=>)��传统知识���G�A.�4.�=�\\'代码>)在var_dump上可能看起来不错,但可能会被丢弃。尝试使用JSON\u INVALID\u UTF8\u IGNORE
作为选项。