Output of json_decode is an object of type stdClass so it is normal to get that error. It is not easy in PHP to cast from one object type to another but you can use this trick:
function f2(array $a){
foreach($a as $element){
f1 ( unserialize ( preg_replace ( "/O:\d+:\"\w+\":(.*)/", "O:1:\"A\":$1", serialize ($element) ) ) )
}
this dirty trick actually cast stdClass to object of type A.
I hope that helps.