0

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

1

2 Answers 2

0

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);
Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately this didn't work - json_decode() expects parameter 1 to be string, object given I'll attempt to cast to a string and see how it goes! Thanks for the direction. Could you advise where in the docs you found this?
oops i didnt read far enough into their API ( i just skimmed the first part) ... it looks like these objects just store key-value pairs
also i was looking at their REST API (which says it returns JSON) and not the PHP API As you said you were using.
0

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.