0

我有以下代码:

$js =   json_decode('{"points": [["39.67495589920286","19.799004793167114"],["39.69503584333047","19.854623079299927"],["39.700847368881","19.89471673965454"],["39.77054750039529","19.96612787246704"],["39.791127230787914","19.956514835357666"],["39.83121363626412","19.849398136138916"],["39.80800856647987","19.793779850006104"],["39.80167855121973","19.70726251602173"],["39.809063512364865","19.66881036758423"],["39.75154536393759","19.617998600006104"],["39.67284188119943","19.664690494537354"],["39.64059509088576","19.709322452545166"],["39.65645604812829","19.747774600982666"]],"meta": {"lat" : "39.60330292590828","lng" : "19.88315624618531","type" : "roadmap","zoom" : "11"}}');

echo "<pre>";
print_r($js);
echo "</pre>";

虽然在http://writecodeonline.com/php/我的代码被正常解码,但在我的本地 PHP 脚本中返回 null。

我也只得到了json数据(下面的json):

{
    "points": [
        [
            "39.67495589920286",
            "19.799004793167114"
        ],
        [
            "39.69503584333047",
            "19.854623079299927"
        ],
        [
            "39.700847368881",
            "19.89471673965454"
        ],
        [
            "39.77054750039529",
            "19.96612787246704"
        ],
        [
            "39.791127230787914",
            "19.956514835357666"
        ],
        [
            "39.83121363626412",
            "19.849398136138916"
        ],
        [
            "39.80800856647987",
            "19.793779850006104"
        ],
        [
            "39.80167855121973",
            "19.70726251602173"
        ],
        [
            "39.809063512364865",
            "19.66881036758423"
        ],
        [
            "39.75154536393759",
            "19.617998600006104"
        ],
        [
            "39.67284188119943",
            "19.664690494537354"
        ],
        [
            "39.64059509088576",
            "19.709322452545166"
        ],
        [
            "39.65645604812829",
            "19.747774600982666"
        ]
    ],
    "meta": {
        "lat" : "39.60330292590828",
        "lng" : "19.88315624618531",
        "type" : "roadmap",
        "zoom" : "11"
    }
}

并在http://jsonlint.com/和这里http://www.jsoneditoronline.org/上验证它们,并且代码看起来很好。

同样在过去,我在我的代码中使用了相同的功能并且工作正常。

是否必须为 json_decode 设置任何选项?我可以做错什么吗?我不明白为什么:?

注意我:我的 phpinfo() 返回:

json support    enabled
json version    1.2.1

注二:今天我使用了这个函数http://aidanlister.com/2004/04/viewing-binary-data-as-a-hexdump-in-php/为了得到我的数据的十六进制图,数据是以下:

0000  7b 26 71 75 6f 74 3b 70  6f 69 6e 74 73 26 71 75   {&quot;p oints&qu
0010  6f 74 3b 3a 20 5b 5b 26  71 75 6f 74 3b 33 39 2e   ot;: [[& quot;39.
0020  36 37 34 39 35 35 38 39  39 32 30 32 38 36 26 71   67495589 920286&q
0030  75 6f 74 3b 2c 26 71 75  6f 74 3b 31 39 2e 37 39   uot;,&qu ot;19.79
0040  39 30 30 34 37 39 33 31  36 37 31 31 34 26 71 75   90047931 67114&qu
0050  6f 74 3b 5d 2c 5b 26 71  75 6f 74 3b 33 39 2e 36   ot;],[&q uot;39.6
0060  39 35 30 33 35 38 34 33  33 33 30 34 37 26 71 75   95035843 33047&qu
0070  6f 74 3b 2c 26 71 75 6f  74 3b 31 39 2e 38 35 34   ot;,&quo t;19.854
0080  36 32 33 30 37 39 32 39  39 39 32 37 26 71 75 6f   62307929 9927&quo
0090  74 3b 5d 2c 5b 26 71 75  6f 74 3b 33 39 2e 37 30   t;],[&qu ot;39.70
00a0  30 38 34 37 33 36 38 38  38 31 26 71 75 6f 74 3b   08473688 81&quot;
00b0  2c 26 71 75 6f 74 3b 31  39 2e 38 39 34 37 31 36   ,&quot;1 9.894716
00c0  37 33 39 36 35 34 35 34  26 71 75 6f 74 3b 5d 2c   73965454 &quot;],
00d0  5b 26 71 75 6f 74 3b 33  39 2e 37 37 30 35 34 37   [&quot;3 9.770547
00e0  35 30 30 33 39 35 32 39  26 71 75 6f 74 3b 2c 26   50039529 &quot;,&
00f0  71 75 6f 74 3b 31 39 2e  39 36 36 31 32 37 38 37   quot;19. 96612787
0100  32 34 36 37 30 34 26 71  75 6f 74 3b 5d 2c 5b 26   246704&q uot;],[&
0110  71 75 6f 74 3b 33 39 2e  37 39 31 31 32 37 32 33   quot;39. 79112723
0120  30 37 38 37 39 31 34 26  71 75 6f 74 3b 2c 26 71   0787914& quot;,&q
0130  75 6f 74 3b 31 39 2e 39  35 36 35 31 34 38 33 35   uot;19.9 56514835
0140  33 35 37 36 36 36 26 71  75 6f 74 3b 5d 2c 5b 26   357666&q uot;],[&
0150  71 75 6f 74 3b 33 39 2e  38 33 31 32 31 33 36 33   quot;39. 83121363
0160  36 32 36 34 31 32 26 71  75 6f 74 3b 2c 26 71 75   626412&q uot;,&qu
0170  6f 74 3b 31 39 2e 38 34  39 33 39 38 31 33 36 31   ot;19.84 93981361
0180  33 38 39 31 36 26 71 75  6f 74 3b 5d 2c 5b 26 71   38916&qu ot;],[&q
0190  75 6f 74 3b 33 39 2e 38  30 38 30 30 38 35 36 36   uot;39.8 08008566
01a0  34 37 39 38 37 26 71 75  6f 74 3b 2c 26 71 75 6f   47987&qu ot;,&quo
01b0  74 3b 31 39 2e 37 39 33  37 37 39 38 35 30 30 30   t;19.793 77985000
01c0  36 31 30 34 26 71 75 6f  74 3b 5d 2c 5b 26 71 75   6104&quo t;],[&qu
01d0  6f 74 3b 33 39 2e 38 30  31 36 37 38 35 35 31 32   ot;39.80 16785512
01e0  31 39 37 33 26 71 75 6f  74 3b 2c 26 71 75 6f 74   1973&quo t;,&quot
01f0  3b 31 39 2e 37 30 37 32  36 32 35 31 36 30 32 31   ;19.7072 62516021
0200  37 33 26 71 75 6f 74 3b  5d 2c 5b 26 71 75 6f 74   73&quot; ],[&quot
0210  3b 33 39 2e 38 30 39 30  36 33 35 31 32 33 36 34   ;39.8090 63512364
0220  38 36 35 26 71 75 6f 74  3b 2c 26 71 75 6f 74 3b   865&quot ;,&quot;
0230  31 39 2e 36 36 38 38 31  30 33 36 37 35 38 34 32   19.66881 03675842
0240  33 26 71 75 6f 74 3b 5d  2c 5b 26 71 75 6f 74 3b   3&quot;] ,[&quot;
0250  33 39 2e 37 35 31 35 34  35 33 36 33 39 33 37 35   39.75154 53639375
0260  39 26 71 75 6f 74 3b 2c  26 71 75 6f 74 3b 31 39   9&quot;, &quot;19
0270  2e 36 31 37 39 39 38 36  30 30 30 30 36 31 30 34   .6179986 00006104
0280  26 71 75 6f 74 3b 5d 2c  5b 26 71 75 6f 74 3b 33   &quot;], [&quot;3
0290  39 2e 36 37 32 38 34 31  38 38 31 31 39 39 34 33   9.672841 88119943
02a0  26 71 75 6f 74 3b 2c 26  71 75 6f 74 3b 31 39 2e   &quot;,& quot;19.
02b0  36 36 34 36 39 30 34 39  34 35 33 37 33 35 34 26   66469049 4537354&
02c0  71 75 6f 74 3b 5d 2c 5b  26 71 75 6f 74 3b 33 39   quot;],[ &quot;39
02d0  2e 36 34 30 35 39 35 30  39 30 38 38 35 37 36 26   .6405950 9088576&
02e0  71 75 6f 74 3b 2c 26 71  75 6f 74 3b 31 39 2e 37   quot;,&q uot;19.7
02f0  30 39 33 32 32 34 35 32  35 34 35 31 36 36 26 71   09322452 545166&q
0300  75 6f 74 3b 5d 2c 5b 26  71 75 6f 74 3b 33 39 2e   uot;],[& quot;39.
0310  36 35 36 34 35 36 30 34  38 31 32 38 32 39 26 71   65645604 812829&q
0320  75 6f 74 3b 2c 26 71 75  6f 74 3b 31 39 2e 37 34   uot;,&qu ot;19.74
0330  37 37 37 34 36 30 30 39  38 32 36 36 36 26 71 75   77746009 82666&qu
0340  6f 74 3b 5d 5d 2c 26 71  75 6f 74 3b 6d 65 74 61   ot;]],&q uot;meta
0350  26 71 75 6f 74 3b 3a 20  7b 26 71 75 6f 74 3b 6c   &quot;:  {&quot;l
0360  61 74 26 71 75 6f 74 3b  20 3a 20 26 71 75 6f 74   at&quot;  : &quot
0370  3b 33 39 2e 36 30 33 33  30 32 39 32 35 39 30 38   ;39.6033 02925908
0380  32 38 26 71 75 6f 74 3b  2c 26 71 75 6f 74 3b 6c   28&quot; ,&quot;l
0390  6e 67 26 71 75 6f 74 3b  20 3a 20 26 71 75 6f 74   ng&quot;  : &quot
03a0  3b 31 39 2e 38 38 33 31  35 36 32 34 36 31 38 35   ;19.8831 56246185
03b0  33 31 26 71 75 6f 74 3b  2c 26 71 75 6f 74 3b 74   31&quot; ,&quot;t
03c0  79 70 65 26 71 75 6f 74  3b 20 3a 20 26 71 75 6f   ype&quot ; : &quo
03d0  74 3b 72 6f 61 64 6d 61  70 26 71 75 6f 74 3b 2c   t;roadma p&quot;,
03e0  26 71 75 6f 74 3b 7a 6f  6f 6d 26 71 75 6f 74 3b   &quot;zo om&quot;
03f0  20 3a 20 26 71 75 6f 74  3b 31 31 26 71 75 6f 74    : &quot ;11&quot
0400  3b 7d 7d                                           ;}}

不幸的是,我仍然无法在该数据中发现错误。

4

0 回答 0