简体   繁体   中英

Parse.com PHP API Converting Object to Array

Using the Parse PHP API - I am calling a query to return an object from the table which is working great. Upon var_dump($parseobjecthere) I receive a nice hierarchical output of the object which I'd like to convert to an associative array. Does anybody have any suggestions for how this may happen - as I can't seem to locate anything relevant in the documentation.

Thanks in advance,

Sean

I just checked their docs and they say they return JSON so perhaps all you need to do is :

$array = json_decode($parseobjecthere, 1);

print_r($array);

I'm not sure it's a full answer - so I'll leave the question open to see if somebody with better skill than myself can give a more appropriate answer.

In my solution - I only needed to extract the serverData element which was protected. Upon casting the object to an array - the key *serverData was extracted using the null character format - (array) $parseObject["\\0*\\0serverData"]

This can then be iterated through as a standard array.

Thanks for the input from everybody. It seems like there must be a better way around doing it so the function is still marked with //TODO - Rejig this !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM