victorsk Posted May 19, 2010 Share Posted May 19, 2010 Hi everyone, I've got a custom Web_Services_Object object which I am trying to encode with json_encode(), store it in MySQL DB, then json_decode() back to use it. The problem is that after applying json_decode(), this object becomes stdClass and it must be Web_Services_Object type. Here is a snapshot of what I have: $client = new Web_Services_Object; $client->CallAPI(); $obj = json_encode($client); After json_decode($obj) is done, I get stdClass Object for: $myObj = json_decode($obj); //is stdClass But I need it to be of type Web_Services_Object. Please, I am not very knowledgeable with PHP, could you please provide an example how this could be done? I think it has something to do with serializing object but I have no idea how to implement it. Thank you, Victor. Quote Link to comment Share on other sites More sharing options...
trq Posted May 19, 2010 Share Posted May 19, 2010 Just serialize it. Json doesn't stand for Javascript object notation for nothing. Quote Link to comment Share on other sites More sharing options...
victorsk Posted May 19, 2010 Author Share Posted May 19, 2010 Hi, I got it. What I was missing is to apply unserialize() on the object after that. Thanks, Victor. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.