使用json_decode无法解析json

json 2017-07-28

在接入合作方接口时,遇到一个json无法解析出来代码如下:

  

<?php
        $res='{"resultcode":007,"resMsg":"!&!lB5:aHb-\/5hb\\Frx;%\/&>:]u&;=>foFBW>&!\"2&()o\\MN$i&J\'w9@"}';// 模拟合作方穿过的json数据 
        $date = json_decode($res,true);
        var_dump($date);
?>

  由于无法解析json数据导致接口无法接入,到网上查了一些资料,都是说一些php配置无效,使用单引号,没有转义之类的,后来仔细检测,发现我这边都不存在这样的问题,最后找出了真正原因,原来是因为resultcode后面的参数导致,json_decode在解析json时会检测json中的类型,由于resultcode后面的参数没有加双号,json_decode会按int类型检测,但是以0开头又不属于int类型,所以会传回一个null,导致我这边无法获取到json数据。

  正确的形式,应该如下:

  

<?php
        $res='{"resultcode":007,"resMsg":"!&!lB5:aHb-\/5hb\\Frx;%\/&>:]u&;=>foFBW>&!\"2&()o\\MN$i&J\'w9@"}';// 模拟合作方穿过的json数据 
        $date = json_decode($res,true);
        var_dump($date);
?>

总的来说是合作方那边回传的json问题,这个问题在别的语言解析时也可能会遇到,今天贴出来,希望能帮助大家。


本文由 admin 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。

2826 条评论

  1. dnldveyysn
    dnldveyysn

    使用json_decode无法解析json - 青花瓷
    adnldveyysn
    dnldveyysn http://www.g7ncs91em1re9eay3a6r26w260b805j4s.org/
    [url=http://www.g7ncs91em1re9eay3a6r26w260b805j4s.org/]udnldveyysn[/url]

  2. fijnezozyd
    fijnezozyd

    使用json_decode无法解析json - 青花瓷
    fijnezozyd http://www.gyw85gkkho3b874pos7jb20829066jl0s.org/
    afijnezozyd
    [url=http://www.gyw85gkkho3b874pos7jb20829066jl0s.org/]ufijnezozyd[/url]

    1. Air Jordan 12 Gym Red
      Air Jordan 12 Gym Red

      Yeezy Shoes http://www.yeezy.com.co/
      Yeezys http://www.yeezys.us.com/
      Yeezy Shoes http://www.yeezysupply.us.com/
      Yeezy Boost 350 http://www.yeezy-shoes.us.com/
      Yeezy Boost http://www.yeezy-boost350.com/
      Yeezy Boost http://www.yeezyboost350.us.com/
      Yeezy Blue Tint http://www.yeezybluetint.com/
      Yeezy 500 http://www.yeezy500utilityblack.com/
      Yeezy 500 http://www.yeezy500utilityblack.us/
      Nike Air VaporMax http://www.vapor-max.org.uk/
      Salomon http://www.salomon-shoes.org.uk/
      Salomon http://www.salomons.me.uk/
      Salomon Shoes http://www.salomonspeedcross4.org.uk/
      Off White Jordan http://www.offwhitejordan1.com/
      Nike VaporMax http://www.nikevapormax.org.uk/
      React Element 87 http://www.nikereactelement87.us.com/
      Nike Element 87 http://www.nikereactelement87.us/
      Nike Vapormax Plus http://www.nikeplus.us/
      Nike Outlet Online http://www.nike--outlet.us/
      Nike Outlet Store Online Shopping http://www.nikeoutletstoreonlineshopping.us/
      Nike Outlet http://www.nikeoutletonlineshopping.us/
      Cheap Nike NBA Jerseys http://www.nikenbajerseys.us/
      Air Max Nike http://www.nikeairmax.us/
      Nike Air Max 2017 http://www.max2017.us/
      Jordan Shoes 2018 http://www.jordan-com.com/
      Jordan 11 Concord http://www.jordan11-concord.com/
      Cheap Yeezy Boost http://www.cs7boots1.com/
      Wholesale Cheap NBA Jerseys http://www.cheapnba-jerseys.us/
      Birkenstock UK http://www.birkenstocksandalsuk.me.uk/
      Basketball Jersey http://www.basketball-jersey.us/
      Balenciaga http://www.balenciaga.me.uk/
      Balenciaga UK http://www.balenciagauk.org.uk/
      Balenciaga UK http://www.balenciagatriples.org.uk/
      Balenciaga UK http://www.birkenstocks.me.uk/
      Balenciaga Trainers http://www.balenciagatrainers.org.uk/
      Air Max 270 http://www.airmax270.org.uk/
      Adidas Yeezys http://www.adidasyeezyshoes.org.uk/
      Adidas Yeezy http://www.adidasyeezyshoes.org.uk/

      1. lsanielpdutpw
        lsanielpdutpw

        yststlkvllcd canadian pharmacy cialis 20mg buying viagra online canadian pharmacy+cialis prescription pfizer viagra from canada
        viagra best price

    2. rxanielhyigsj
      rxanielhyigsj

      ebtddhkzbmvq canadian pharmacy tadalafil [url=http://northwestpharmacyph.com/]viagra professional[/url] best price cialis canadian pharmacy discount cialis
      womens viagra

  3. mljfkyntv
    mljfkyntv

    使用json_decode无法解析json - 青花瓷
    amljfkyntv
    [url=http://www.go4uf78cz9j3a686oud6p92n1zk0932ls.org/]umljfkyntv[/url]
    mljfkyntv http://www.go4uf78cz9j3a686oud6p92n1zk0932ls.org/

    1. Nike Outlet satore
      Nike Outlet satore

      Jordan 12 Gym Red http://www.jordan12gymred.us.com/
      nike factory outlet http://www.nikefactoryoutletstoreonline.com/
      Nike Outlet satore http://www.nikefactoryoutletstoreonline.us/
      Nike Outlet http://www.nikestores.us.com/
      jordan 33 http://www.jordan33.us/
      cheapjerseysfromchina http://www.cheapjerseysfromchina.us/
      custom nfl jerseys http://www.customnfljerseys.us/
      jordan 11 concord 2018 http://www.jordan11concord.us.com/
      Jordan 12 Gym Red 2018 http://www.jordan12gymred.us/
      Jordan 12 Gym Red http://www.redjordan12.us/
      Yeezy http://www.yeezy.com.co/
      Yeezy Shoes http://www.yeezys.us.com/

    2. air jordan 33
      air jordan 33

      Jordan 12 Gym Red 2018 http://www.jordan12gymred.us.com/
      nike factory outlet http://www.nikefactoryoutletstoreonline.com/
      Nike Outlet satore http://www.nikefactoryoutletstoreonline.us/
      Nike Outlet satore http://www.nikestores.us.com/
      jordan 33 http://www.jordan33.us/
      cheapjerseysfromchina http://www.cheapjerseysfromchina.us/
      cheap custom nfl jerseys http://www.customnfljerseys.us/
      air jordan 11 concord http://www.jordan11concord.us.com/
      Jordan 12 Gym Red 2018 http://www.jordan12gymred.us/
      Jordan 12 Gym Red 2018 http://www.redjordan12.us/
      Yeezys http://www.yeezy.com.co/
      Yeezy http://www.yeezys.us.com/
      Yeezy Shoes http://www.yeezysupply.us.com/
      Yeezy Boost 350 http://www.yeezy-shoes.us.com/
      Yeezy Boost http://www.yeezy-boost350.com/
      Yeezy Boost 350 http://www.yeezyboost350.us.com/
      Yeezy Boost 350 V2 Blue Tint http://www.yeezybluetint.com/
      Yeezy 500 Utility Black http://www.yeezy500utilityblack.com/
      Adidas Yeezy 500 http://www.yeezy500utilityblack.us/
      Nike Air VaporMax http://www.vapor-max.org.uk/
      Salomon http://www.salomon-shoes.org.uk/
      Salomon http://www.salomons.me.uk/
      Salomon Shoes http://www.salomonspeedcross4.org.uk/
      Off White Jordan 1 http://www.offwhitejordan1.com/
      Nike VaporMax http://www.nikevapormax.org.uk/
      Nike React Element 87 http://www.nikereactelement87.us.com/
      Nike React Element 87 http://www.nikereactelement87.us/
      Nike Plus http://www.nikeplus.us/
      Nike Outlet Online http://www.nike--outlet.us/
      Nike Outlet http://www.nikeoutletstoreonlineshopping.us/
      Nike Outlet http://www.nikeoutletonlineshopping.us/
      Cheap Nike NBA Jerseys http://www.nikenbajerseys.us/
      Nike Air Max http://www.nikeairmax.us/
      Air Max 2017 http://www.max2017.us/
      Jordan Shoes http://www.jordan-com.com/
      Jordan 11 Concord http://www.jordan11-concord.com/
      Kanye West Yeezys Boost Shoes http://www.cs7boots1.com/
      Cheap NBA Jerseys http://www.cheapnba-jerseys.us/
      Birkenstock UK http://www.birkenstocksandalsuk.me.uk/
      Basketball Jersey http://www.basketball-jersey.us/
      Balenciaga UK http://www.balenciaga.me.uk/
      Balenciaga http://www.balenciagauk.org.uk/
      Balenciaga http://www.balenciagatriples.org.uk/
      Balenciaga http://www.birkenstocks.me.uk/
      Balenciaga UK http://www.balenciagatrainers.org.uk/
      Air Max 270 http://www.airmax270.org.uk/
      Yeezy Shoes http://www.adidasyeezyshoes.org.uk/
      Adidas Yeezy http://www.adidasyeezyshoes.org.uk/

      1. ArtemevaYaromira89scied
        ArtemevaYaromira89scied

        at is site

        c471 is acquisto online

    3. Yeezy Boost 350
      Yeezy Boost 350

      Jordan 12 Gym Red http://www.jordan12gymred.us.com/
      nike factory outlet store online http://www.nikefactoryoutletstoreonline.com/
      nike factory outlet store online http://www.nikefactoryoutletstoreonline.us/
      Nike Outlet http://www.nikestores.us.com/
      jordan 33 http://www.jordan33.us/
      cheapjerseysfromchina http://www.cheapjerseysfromchina.us/
      nfl jerseys http://www.customnfljerseys.us/
      air jordan 11 concord http://www.jordan11concord.us.com/
      Jordan 12 Gym Red 2018 http://www.jordan12gymred.us/
      Jordan 12 Gym Red 2018 http://www.redjordan12.us/
      Yeezy Shoes http://www.yeezy.com.co/
      Yeezys http://www.yeezys.us.com/
      Yeezy Shoes http://www.yeezysupply.us.com/
      Yeezy Boost 350 http://www.yeezy-shoes.us.com/
      Yeezy Boost http://www.yeezy-boost350.com/
      Yeezy Boost 350 V2 http://www.yeezyboost350.us.com/
      Yeezy Boost 350 V2 Blue Tint http://www.yeezybluetint.com/
      Yeezy 500 Utility Black http://www.yeezy500utilityblack.com/
      Yeezy 500 http://www.yeezy500utilityblack.us/
      Vapor Max http://www.vapor-max.org.uk/
      Salomon Shoes http://www.salomon-shoes.org.uk/
      Salomon Shoes http://www.salomons.me.uk/
      Salomon Shoes http://www.salomonspeedcross4.org.uk/
      Off White Jordan http://www.offwhitejordan1.com/
      Vapor Max http://www.nikevapormax.org.uk/
      Nike React Element 87 http://www.nikereactelement87.us.com/
      Nike React Element 87 http://www.nikereactelement87.us/
      Nike Plus http://www.nikeplus.us/
      Nike Outlet Online http://www.nike--outlet.us/
      Nike Outlet Store http://www.nikeoutletstoreonlineshopping.us/
      Nike Outlet Store http://www.nikeoutletonlineshopping.us/
      Cheap Nike NBA Jerseys http://www.nikenbajerseys.us/
      Air Max Nike http://www.nikeairmax.us/
      Air Max 2017 http://www.max2017.us/
      Jordan Shoes 2018 http://www.jordan-com.com/
      Jordan 11 Concord http://www.jordan11-concord.com/
      Cheap Yeezy Boost http://www.cs7boots1.com/
      Wholesale Cheap NBA Jerseys http://www.cheapnba-jerseys.us/
      Birkenstock Sandals UK http://www.birkenstocksandalsuk.me.uk/
      NBA Jerseys http://www.basketball-jersey.us/
      Balenciaga http://www.balenciaga.me.uk/
      Balenciaga UK http://www.balenciagauk.org.uk/
      Balenciaga UK http://www.balenciagatriples.org.uk/
      Balenciaga UK http://www.birkenstocks.me.uk/
      Balenciaga http://www.balenciagatrainers.org.uk/
      Nike Air Max http://www.airmax270.org.uk/
      Yeezy Shoes http://www.adidasyeezyshoes.org.uk/
      Adidas Yeezy Shoes http://www.adidasyeezyshoes.org.uk/

      1. ArtemevaYaromira89scied
        ArtemevaYaromira89scied

        is daily bestellen

        c471 farmacia de is nyc

        1. Szlorsof
          Szlorsof

          It is wholly fabulous that today I was looking inasmuch as something to submit me a jerk of happiness. The grotesque thing is that I found it in the senior place. I was struggling to make money to get my hire paid, and I could not idol entirely what to do. Some friends gave me a few special options, but I till was not dedicated to those solutions. However, I finally figured out that I right-minded needed to take a look at this website to resolve all my problems: online payday loan

      2. ArtemevaYaromira89scied
        ArtemevaYaromira89scied

        enter site how much is is

        c471 order brand is without rx

        1. ghanielivmhhd
          ghanielivmhhd

          mdkpouonhaaf tadalafil canadian canadian drugs new viagra branded cialis from canada
          pharmacy rx one

    4. MikkerBug
      MikkerBug

      You can hear about our amazing page and get to know how spectacular you can be: onlineblackjack.us.org

  4. jgtqobiif
    jgtqobiif

    使用json_decode无法解析json - 青花瓷
    jgtqobiif http://www.gw37un1cl7q3lw1ue415k42b829g8w5ds.org/
    ajgtqobiif
    [url=http://www.g