0

how to convert array results from ParseQuery() as JSON because the results always return as Array. In addition, am using Slim3 framework for routing.

$query = new ParseQuery("Friends");
$results = $query->find();

I searched a lot but without result.

var_dump results https://pastebin.com/KDYcd5Cd

Any support please

WonderX
  • 95
  • 9

2 Answers2

0

The objects in the array you are trying to json_encode have private properties, which are not accessible when dumping or encoding the object.

However, you can still achieve this by iterating over each object and calling $obj->_encode() individually. This will encode and return the properties that you're looking for.

Given that, something like this would suffice:

$query = new ParseQuery("Friends");
$results = $query->find();

$encoded = [];

// iterate over and store each encoded result
foreach($results as $result) {
    $encoded[] = $result->_encode();
}
montymxb
  • 86
  • 1
  • 6
0

try this code

$query = new ParseQuery("Friends");
$results = $query->find(false, false);
Anecha Sun
  • 105
  • 1
  • 2