次のコードがあります。
$url = "http://myserver/myapp/restapi.php?method=get_list";
$jsondata = curl($url);
print_r($jsondata);
$arrayObjects = json_decode($jsondata, true);
print_r($arrayObjects);
$jsondata の出力は機能しますが、arrayObjects は何も出力しません。適切にダンプされる json データの最初の「レコード」だけを含めました。
{"263":{"realm":"object","etags":
[],"id":"263","name":"ddd","label":"","asset_no":null,"objtype_id":"4",
"r_id":null,"R_name":null,"row_id":null,"Row_name":null,"container_id":null,
"container_name":null,"has_problems":"no","comment":null,"nports":"3",
"runs8021Q":"1","itags":[],"dname":"ddd","atags":[{"tag":"$id_263"},
{"tag":"$typeid_4"},{"tag":"$any_object"},{"tag":"$cn_ddd"},{"tag":"$unmounted"},
{"tag":"$no_asset_tag"},{"tag":"$runs_8Q"},{"tag":"$untagged"}]}
},
画面にエラーメッセージも表示されません。私がトラブルシューティングを試みたのは、このjsonデータを文字列として含む新しいphpファイルを作成することです...そして、jsonデコードを呼び出しました。それは正常に動作します。以下のコードをチェックしてください。
<?php
$jsondata='{"263":{"realm":"object","etags":
[],"id":"263","name":"ddd","label":"","asset_no":null,
"objtype_id":"4","r_id":null,"R_name":null,"row_id":null,
"Row_name":null,"container_id":null,"container_name":null,
"has_problems":"no","comment":null,"nports":"3","runs8021Q":"1","itags":
[],"dname":"ddd","atags":[{"tag":"$id_263"},
{"tag":"$typeid_4"},
{"tag":"$any_object"},{"tag":"$cn_ddd"},{"tag":"$unmounted"},
{"tag":"$no_asset_tag"},{"tag":"$runs_8021Q"},{"tag":"$untagged"}]},"187":
{"realm":"object","etags":[],"id":"187","name":"a-ds-NSM-1",
"label":"","asset_no":null,"objtype_id":"4","r_id":null,
"R_name":null,"row_id":null,"Row_name":null,"container_id":null,
"container_name":null,"has_problems":"no","comment":null,
"nports":"3","runs8021Q":null,"itags":[],
"dname":"ss-a-NSM-1","atags":[{"tag":"$id_187"},{"tag":"$typeid_4"},
{"tag":"$any_object"},{"tag":"$cn_ss-ds-1"},{"tag":"$unmounted"},
{"tag":"$no_asset_tag"},{"tag":"$untagged"}]},
"123":{"realm":"object","etags":
[],"id":"123","name":"df","label":"","asset_no":null,
"objtype_id":"4","r_id":null,"R_name":null,"row_id":null,
"Row_name":null,"container_id":null,"container_name":null,
"has_problems":"no","comment":null,"nports":"3",
"runs8021Q":null,"itags":[],"dname":"df",
"atags":[{"tag":"$id_123"},{"tag":"$typeid_4"},
{"tag":"$any_object"},{"tag":"$cn_df"},
{"tag":"$unmounted"},{"tag":"$no_asset_tag"},{"tag":"$untagged"}]}}';
print_r(json_decode($jsondata,true));
?>
私のコードの何が問題なのかについてのアイデアをいただければ幸いです。