小编Mic*_* C.的帖子

json_encode()转义正斜杠

我从Instagram上拉JSON:

$instagrams = json_decode($response)->data;

然后将变量解析为PHP数组以重构数据,然后重新编码和缓存文件:

file_put_contents($cache,json_encode($results));

当我打开缓存文件时,所有正斜杠"/"都被转义:

http:\/\/distilleryimage4.instagram.com\/410e7...

我从搜索中收集json_encode()自动执行此操作...有没有办法禁用它?

php json

158
推荐指数
2
解决办法
13万
查看次数

json数组中的项数

寻找一个简单的JS来计算.json文件中的项目数(每个项目代表,在这种情况下,一张Instagram照片被拉入网络应用程序;我想计算照片的数量).因此,Json的结构......

{
 "type":"FeatureCollection",
 "features":[
  {
     "type":"Feature",
     "geometry":{
        "coordinates":[
           -79.40916,
           43.87767
        ],
        "type":"Point"
     },
     "properties":{
        "longitude":-79.40916,
        "latitude":43.87767,
        "title":"",
        "user":"cmay2400",
        "id":"176051485697457528_13947894",
        "image":"http:\/\/distilleryimage0.instagram.com\/1d725a3a8d7511e181bd12313817987b_7.jpg",
        "images":{
           "low_resolution":{
              "url":"http:\/\/distilleryimage0.instagram.com\/1d725a3a8d7511e181bd12313817987b_6.jpg",
              "width":306,
              "height":306
           },
           "thumbnail":{
              "url":"http:\/\/distilleryimage0.instagram.com\/1d725a3a8d7511e181bd12313817987b_5.jpg",
              "width":150,
              "height":150
           },
           "standard_resolution":{
              "url":"http:\/\/distilleryimage0.instagram.com\/1d725a3a8d7511e181bd12313817987b_7.jpg",
              "width":612,
              "height":612
           }
        },
        "description":"Today's ride <span class=\"tag\">#zipcar<\/span>",
        "instagram_id":"13947894",
        "likes":1,
        "profile_picture":"http:\/\/images.instagram.com\/profiles\/profile_13947894_75sq_1322267355.jpg"
     }
  },
  {
     "type":"Feature", [...]
Run Code Online (Sandbox Code Playgroud)

我只想循环遍历json文件并计算项目数.完全迷失在哪里开始.

javascript json

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

json ×2

javascript ×1

php ×1