I have this data in JSON:

object(stdClass)#1 (2) { ["noun"]=> object(stdClass)#2 (2) { ["syn"]=> array(59) { [0]=> string(5) "drama" [1]=> string(13) "dramatic play" [2]=> string(8) "maneuver" [3]=> string(9) "manoeuvre" [4]=> string(3) "bid" [5]=> string(12) "child's play" [6]=> string(14) "playing period" [7]=> string(14) "period of play" [8]=> string(9) "free rein" [9]=> string(7) "shimmer" [10]=> string(3) "fun" [11]=> string(5) "sport" [12]=> string(9) "looseness" [13]=> string(6) "frolic" [14]=> string(4) "romp" [15]=> string(6) "gambol" [16]=> string(5) "caper" [17]=> string(4) "turn" [18]=> string(8) "gambling" [19]=> .........

I'm trying to use the following code but getting error:

.....
$json = json_decode ( $body );
echo $json->syn[3];
......

Please suggest me what should i do?

Recommended Answers

All 2 Replies

Where is $body defined?

Do a

var_dump($json);

to see the structure.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.