我有一个连接到dreamfactory的MySQL数据库,但我的一些记录是序列化的(PHP)。每当我发送“GET”网络请求时,我都会编写一个PHP脚本来反序列化它,但它不起作用。我使用AFNetworking从Swift xcode项目获取数据库信息,并希望显示未序列化的信息。
任何人都可以看到我做错了哪一部分? 这是我放置我的PHP脚本和脚本本身的地方:
mysql.table。[表名}。{ID} .get.post_process
$data = $response.meta_value;
function toJSON($theDATA) {
$uns = unserialize(unserialize($theDATA));
$DATA = json_encode($uns);
return $DATA;
}
$new_data = toJSON($data);
return $new_data;
这是php序列化:
{
"meta_value" = "s:306:\"a:1:{i:274;a:1:{s:9:\"schedules\";a:1:{s:13:\"56f5dc96a042f\";a:5:{s:13:\"minutes_start\";s:3:\"540\";s:11:\"minutes_end\";s:4:\"1020\";s:5:\"weeks\";a:7:{i:1;s:2:\"on\";i:2;s:2:\"on\";i:3;s:2:\"on\";i:4;s:2:\"on\";i:5;s:2:\"on\";i:6;s:2:\"on\";i:0;s:2:\"on\";}s:10:\"date_start\";s:10:\"03/25/2016\";s:8:\"date_end\";s:10:\"06/15/2016\";}}}}\";";
}
这就是我想要得到的json body:
{"274":{"schedules":{"56f5dc96a042f":{"minutes_start":"540","minutes_end":"1020","weeks":{"1":"on","2":"on","3":"on","4":"on","5":"on","6":"on","0":"on"},"date_start":"03\/25\/2016","date_end":"06\/15\/2016"}}}}