1. Halo Guest, pastikan Anda selalu menaati peraturan forum sebelum mengirimkan post atau thread baru.

[ask] Bagaimana cara parsing data CNET format JSON

Discussion in 'Pemrograman Web' started by janganan, Jul 29, 2009.

  1. janganan

    janganan Hero

    Joined:
    Feb 11, 2009
    Messages:
    575
    Likes Received:
    13
    Location:
    Depan Laptop
    Hasil query seperti ini
    PHP:
    stdClass Object
    (
        [
    CNETResponse] => stdClass Object
            
    (
                [@
    realm] => cnet
                
    [@version] => 1.0
                
    [SoftwareProducts] => stdClass Object
                    
    (
                        [@
    start] => 0
                        
    [@numReturned] => 2
                        
    [@numFound] => 458
                        
    [SoftwareProduct] => Array
                            (
                                [
    0] => stdClass Object
                                    
    (
                                        [@
    id] => 10879308
                                        
    [@setId] => 10625067
                                        
    [@xlink:href] => http://developer.api.cnet.com/rest/v1.0/softwareProduct?productSetId=10625067&iod=screenshotsPrimary&partKey=&partTag=f3k3ky6j53yayqnmqudtcwbk
                                        
    [Name] => stdClass Object
                                            
    (
                                                [$] => 
    PC Tools AntiVirus Free Edition
                                            
    )

                                       [
    Publisher] => stdClass Object
                                            
    (
                                                [@
    id] => 6257086
                                                
    [Name] => stdClass Object
                                                    
    (
                                                        [$] => 
    PC Tools
                                                    
    )

                                                [
    LinkURL] => stdClass Object
                                                    
    (
                                                        [$] => 
    http://www.pctools.com/
                                                    
    )

                                                [
    UrsRegId] => stdClass Object
                                                    
    (
                                                    )

                                            )

                                        [
    Price] => stdClass Object
                                            
    (
                                                [$] => $
    0.00
                                            
    )

                                        [
    Summary] => stdClass Object
                                            
    (
                                                [$] => 
    Protect your PC against virusesworms, and trojans with rapid updates and IntelliGuard technology.
                                            )

                                        [
    Description] => stdClass Object
                                            
    (
                                                [$] => <
    p>PC Tools AntiVirus Free Edition protects you against the most nefarious cyber-threats attempting to gain access to your PC and personal detailsGoing online without protection against the latest fast-spreading virusesworms and Trojans can result in infections within minutesOnce infectedthe virus will usually attempt to spread itself to your friendsfamily and associates by accessing your e-mail contacts and networked PCsThe infection may also allow hackers to access files on your PC, use it to launch attacks against other computers and Websites or to send mass spam emailThat's why PC Tools AntiVirus Free Edition provides protection, with rapid database updates, IntelliGuard real-time file, Internet & e-mail protection and comprehensive system scanning to ensure your system remains safe and virus free. Version 5 features new improved scan engine, smaller memory footprint, and much improved system performance.</p>
                                            )

                                        [Requirements] => stdClass Object
                                            (
                                                [$] => Windows 2000/XP/Vista
                                            )

                                        [Platform] => stdClass Object
                                            (
                                                [$] => Windows
                                            )

                                        [OperatingSystems] => stdClass Object
                                            (
                                                [OperatingSystem] => Array
                                                    (
                                                        [0] => stdClass Object
                                                            (
                                                                [@id] => 3
                                                                [$] => Windows
                                                            )

                                                        [1] => stdClass Object
                                                            (
                                                                [@id] => 17
                                                                [$] => Windows 2000
                                                            )

                                                        [2] => stdClass Object
                                                            (
                                                                [@id] => 25
                                                                [$] => Windows XP
                                                            )

                                                        [3] => stdClass Object
                                                            (
                                                                [@id] => 52
                                                                [$] => Windows Vista
                                                            )

                                                    )

                                            ) 
                                        [BuyNowUrl] => stdClass Object
                                            (
                                                [@type] => dl_buy_pub
                                                [$] => http://www.pctools.com/free-antivirus/?ref=cnet&utm_source=download.com&utm_medium=PPD&utm_content=ALL&utm_campaign=ppd_av
                                            )

                                          [Category] => stdClass Object
                                            (
                                                [@id] => 2239
                                                [@xlink:href] => http://developer.api.cnet.com/rest/v1.0/category?categoryId=2239&siteId=4&partKey=&partTag=f3k3ky6j53yayqnmqudtcwbk
                                            )

                                        [Screenshots] => stdClass Object
                                            (
                                                [Screenshot] => stdClass Object
                                                    (
                                                        [@id] => 2735441
                                                        [@isPrimary] => true
                                                        [@sequence] => 1
                                                        [Caption] => stdClass Object
                                                            (
                                                                [$] => Main Screen
                                                            )

                                                        [ImageURLs] => stdClass Object
                                                            (
                                                                [ImageURL] => Array
                                                                    (
                                                                        [0] => stdClass Object
                                                                            (
                                                                                [@type] => thumbnail
                                                                                [@width] => 104
                                                                                [@height] => 68
                                                                                [$] => http://i.d.com.com/i/dl/media/dlimage/13/44/98/134498_thumbnail.jpeg
                                                                            )

                                                                        [1] => stdClass Object
                                                                            (
                                                                                [@type] => small
                                                                                [@width] => 160
                                                                                [@height] => 120
                                                                                [$] => http://i.d.com.com/i/dl/media/dlimage/13/44/98/134498_small.jpeg
                                                                            )

                                                                    )

                                                            )

                                                    )

                                            )

                                        [Icons] => stdClass Object
                                            (
                                            )

                                        [EditorsPick] => stdClass Object
                                            (
                                            )

                                    )


                            )

                    )

            )

    )
    Gimana cara ambil Name, description ama Screenshots?
     
  2. janganan

    janganan Hero

    Joined:
    Feb 11, 2009
    Messages:
    575
    Likes Received:
    13
    Location:
    Depan Laptop
    update untuk Nama dan desc udah bisa dengan script ini


    PHP:
    foreach ($json->CNETResponse->SoftwareProducts->SoftwareProduct as $searchresult)
        {
            foreach(
    $searchresult->Name as $nama){print '<h2>'.$nama.' ';}
            foreach(
    $searchresult->Description as $nama){print $nama.'<br />';}
    benerkah cara saya di atas?

    trus gimana cara ambil yang screenshot???
     
  3. janganan

    janganan Hero

    Joined:
    Feb 11, 2009
    Messages:
    575
    Likes Received:
    13
    Location:
    Depan Laptop
    om Ngkong, Kang Pogung, Kang Doneeh,,ato sapa aja deh,,,,
    help me :hmm:
     
  4. Pogung177

    Pogung177 Banned

    Joined:
    Sep 25, 2005
    Messages:
    1,994
    Likes Received:
    45
    Kenapa gak pilih XML aja, ntar parsenya pake SimpleXML PHP5
     
  5. janganan

    janganan Hero

    Joined:
    Feb 11, 2009
    Messages:
    575
    Likes Received:
    13
    Location:
    Depan Laptop
    :silau: ternyata pake SimpleXML PHP5 lebih gampang...makasih om:gembira:
     

Share This Page