3 Replies - 852 Views - Last Post: 04 July 2015 - 04:56 AM Rate Topic: -----

#1 mutago234  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 248
  • Joined: 08-September 13

convert stdClass Object to Json Array in php

Posted 03 July 2015 - 01:16 PM

i have the following stdclass object below. How can I convert it to Json Array in php

Thanks

       stdClass Object
    (
        [id] => 3341234
        [id_str] => 33414123
        [email] => [email protected]
        [screen_name] => chibaco
        [location] => 
        [description] => 
        [url] => 
        [entities] => stdClass Object
            (
                [description] => stdClass Object
                    (
                        [urls] => Array
                            (
                            )
    
                    )
    
            )
    
        [protected] => 
        [followers_count] => 8
        [friends_count] => 41
        [listed_count] => 0
        [created_at] => Mon Jun 22 14:59:08 +0000 2015
        [favourites_count] => 0
        [utc_offset] => 
        [time_zone] => 
        [geo_enabled] => 
        [verified] => 
        [statuses_count] => 0
        [lang] => en
        [contributors_enabled] => 
        [is_translator] => 
        [is_translation_enabled] => 
        [profile_background_color] => C0DEED
        [profile_background_image_url] => http://abs.twimg.com/images/themes/theme1/bg.png
        [profile_background_image_url_https] => https://abs.twimg.com/images/themes/theme1/bg.png
        [profile_background_tile] => 
        [profile_image_url] => http://pbs.twimg.com/profile_images/612999068701335552/VIbF69MX_normal.jpg
        [profile_image_url_https] => https://pbs.twimg.com/profile_images/612999068701335552/VIbF69MX_normal.jpg
        [profile_link_color] => 0084B4
        [profile_sidebar_border_color] => C0DEED
        [profile_sidebar_fill_color] => DDEEF6
        [profile_text_color] => 333333
        [profile_use_background_image] => 1
        [has_extended_profile] => 
        [default_profile] => 1
        [default_profile_image] => 
        [following] => 
        [follow_request_sent] => 
        [notifications] => 
    )




Is This A Good Question/Topic? 0
  • +

Replies To: convert stdClass Object to Json Array in php

#2 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2342
  • View blog
  • Posts: 9,393
  • Joined: 03-December 12

Re: convert stdClass Object to Json Array in php

Posted 03 July 2015 - 01:28 PM

Have you looked at json_encode?
Was This Post Helpful? 0
  • +
  • -

#3 smoqadam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-July 15

Re: convert stdClass Object to Json Array in php

Posted 04 July 2015 - 04:26 AM

you can use json_decode and json_encode like this :

<?php
$array = json_decode(json_encode($stdClass),true);


This post has been edited by andrewsw: 04 July 2015 - 04:57 AM
Reason for edit:: Removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • say what now
  • member icon

Reputation: 6409
  • View blog
  • Posts: 25,892
  • Joined: 12-December 12

Re: convert stdClass Object to Json Array in php

Posted 04 July 2015 - 04:56 AM

Note that there is no need to quote the entire original post, there is a REPLY button further down the page.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1