Export to GitHub

php-twitter - issue #6

json_decode typecase error


Posted on Oct 20, 2008 by Grumpy Hippo

What steps will reproduce the problem? 1. use this code; $t = new Twitter(); $t->username='un';
$t->password='pw'; $r = $t->userTimeline(false, 1); print_r($r); 2. try and access any of object properties... they all have a property name that is a number so you can't

What is the expected output? What do you see instead? expected an array, got an object

What version of the product are you using? On what operating system? 1.0beta, linux, PHP 5.2.6

Please provide any additional information below. Line 466 reads "return (object) json_decode( $data );" if the JSON is an array it returns an array! You then turn it into an object and this makes no sense... there is no need for typecasting here.

if its an object the result ($r as above) would need to be accessed like this;

print_r($r->1);

but thats impossible.

if you take out "(object)" the following code then works fine.

print_r($r[0]);

Comment #1

Posted on Feb 28, 2009 by Happy Monkey

Fixed in r65

Status: Fixed

Labels:
Type-Defect Priority-Medium