Jump to content

[SOLVED] reading JSON structure


ravi181229

Recommended Posts

Hi,

 

I would like to read the JSON structure and print the values.

 

when I do print_r($theChannels);  I am getting following JSON structure:

 

Array

(

    [items] => Array

        (

            [0] => Array

                (

                    [uri] => channels/115180

                    [tags] =>               

                    [title] => jePRoCKs

                    [permalink] => http://www.kyte.tv/ch/115180-jeprocks

                    [viewerCount] => 19

                    [synopsis] =>

                    [totalMessageCount] => 376976

                    [totalWatches] => 28706

                    [lastMessageTime] => 20081105T221351Z

                    [thumbUrl120x90] => http://media01.kyte.tv/store/007/01/crr/0811/05/22/953100-107858-stuffedanimalsfunnycommercial_wm_120_90-tom-1000.jpg?h=712e3edf16ee71465c9fcbe0ceae1860

                    [chatThreadUri] => messageThread/101871

                    [channelHomeUrl] =>

                    [showCount] => 52

                    [lastShowTime] => 20081105T221240Z

                    [ownerName] => jePRoCKs

                    [ownerUri] => users/107858

                    [createdTime] => 20080822T164215Z

                    [modifiedTime] => 20081103T181951Z

                    [class] => com.kyte.api.model.Channel

                )

 

            [1] => Array

                (

                    [uri] => channels/29147

                    [tags] => kristen, radikal

                    [title] => RADIKALT LIV MISSION - WEBTV

                    [permalink] => http://www.kyte.tv/ch/29147-radikalt-liv-mission-webtv

                    [viewerCount] => 4

                    [synopsis] => En radikalt kristen tv-kanal

                    [totalMessageCount] => 5

                    [totalWatches] => 80

                    [lastMessageTime] => 20071202T100159Z

                    [thumbUrl120x90] => http://media10.kyte.tv/store/007/10/crr/0811/05/22/953097-28588-media_120_90.jpg?h=4f5c34d9c1b10382f6ac16d5feb279b7

                    [chatThreadUri] => messageThread/6457

                    [channelHomeUrl] => http://RADIKALT LIV MISSION-WEB TV

                    [showCount] => 6

                    [lastShowTime] => 20081105T221125Z

                    [ownerName] => radikalt

                    [ownerUri] => users/28588

                    [createdTime] => 20071201T140748Z

                    [modifiedTime] => 20071202T004809Z

                    [class] => com.kyte.api.model.Channel

                )

 

        )

 

    [totalSize] => 26753

    [class] => com.kyte.api.model.Page

)

 

need help.

 

Thanks,

Ravi

Link to comment
https://forums.phpfreaks.com/topic/131550-solved-reading-json-structure/
Share on other sites

I see..

 

Well, you could read that data like this:

 

<?php
include('lib/JSON.php');

//make a new json parser
$json = new Services_JSON;

//decode incoming JSON string
$jsonRequest = $json->decode($theChannels);

echo 'Class: ' . $jsonRequest['class'] . '<br />';
echo 'Total Size: ' . $jsonRequest['totalSize'] . '<br />';
echo 'Items: <br />';
foreach ($jsonRequest['items'] as $item) {
    echo '<ul>';
    foreach ($item as $key => $value) {
        echo "<li>$key = $value</li>";
    }
    echo '</ul>';
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.