PHP - How to convert ParseObject to JSON?

I am getting ParseObject from request and I need to convert it to json.

When I do print_r ($ results) I get a lot of stuff, but when I do $ json = json_encode ($ results) and print it, $ json is empty.

Here is the var_dump result from $ results:

array (size=5)
  0 => 
    object(Parse\ParseObject)[12]
      protected 'serverData' => 
        array (size=1)
          'Usuario_FK' => 
            object(Parse\ParseUser)[15]
              ...
      protected 'operationSet' => 
        array (size=0)
          empty
      private 'estimatedData' => 
        array (size=1)
          'Usuario_FK' => 
            object(Parse\ParseUser)[15]
              ...
      private 'dataAvailability' => 
        array (size=1)
          'Usuario_FK' => boolean true
      private 'className' => string 'Asistencia' (length=10)
      private 'objectId' => string 'mdHR3ZZo6z' (length=10)
      private 'createdAt' => 
        object(DateTime)[13]
          public 'date' => string '2015-06-10 01:17:13' (length=19)
          public 'timezone_type' => int 2
          public 'timezone' => string 'Z' (length=1)
      private 'updatedAt' => 
        object(DateTime)[14]
          public 'date' => string '2015-06-13 13:34:05' (length=19)
          public 'timezone_type' => int 2
          public 'timezone' => string 'Z' (length=1)
      private 'hasBeenFetched' => boolean false
  1 => 
    object(Parse\ParseObject)[21]
      protected 'serverData' => 
        array (size=1)
          'Usuario_FK' => 
            object(Parse\ParseUser)[24]
              ...
      protected 'operationSet' => 
        array (size=0)
          empty
      private 'estimatedData' => 
        array (size=1)
          'Usuario_FK' => 
            object(Parse\ParseUser)[24]
              ...
      private 'dataAvailability' => 
        array (size=1)
          'Usuario_FK' => boolean true
      private 'className' => string 'Asistencia' (length=10)
      private 'objectId' => string '3DK19BWOYY' (length=10)
      private 'createdAt' => 
        object(DateTime)[22]
          public 'date' => string '2015-06-10 01:08:14' (length=19)
          public 'timezone_type' => int 2
          public 'timezone' => string 'Z' (length=1)
      private 'updatedAt' => 
        object(DateTime)[23]
          public 'date' => string '2015-06-13 13:34:09' (length=19)
          public 'timezone_type' => int 2
          public 'timezone' => string 'Z' (length=1)
      private 'hasBeenFetched' => boolean false
  2 => 
    object(Parse\ParseObject)[30]
      protected 'serverData' => 
        array (size=1)
          'Usuario_FK' => 
            object(Parse\ParseUser)[33]
              ...
      protected 'operationSet' => 
        array (size=0)
          empty
      private 'estimatedData' => 
        array (size=1)
          'Usuario_FK' => 
            object(Parse\ParseUser)[33]
              ...
      private 'dataAvailability' => 
        array (size=1)
          'Usuario_FK' => boolean true
      private 'className' => string 'Asistencia' (length=10)
      private 'objectId' => string 'x94VIvFpdq' (length=10)
      private 'createdAt' => 
        object(DateTime)[31]
          public 'date' => string '2015-06-10 01:07:38' (length=19)
          public 'timezone_type' => int 2
          public 'timezone' => string 'Z' (length=1)
      private 'updatedAt' => 
        object(DateTime)[32]
          public 'date' => string '2015-06-13 13:34:11' (length=19)
          public 'timezone_type' => int 2
          public 'timezone' => string 'Z' (length=1)
      private 'hasBeenFetched' => boolean false
  3 => 
    object(Parse\ParseObject)[39]
      protected 'serverData' => 
        array (size=1)
          'Usuario_FK' => 
            object(Parse\ParseUser)[42]
              ...
      protected 'operationSet' => 
        array (size=0)
          empty
      private 'estimatedData' => 
        array (size=1)
          'Usuario_FK' => 
            object(Parse\ParseUser)[42]
              ...
      private 'dataAvailability' => 
        array (size=1)
          'Usuario_FK' => boolean true
      private 'className' => string 'Asistencia' (length=10)
      private 'objectId' => string 'z4vtVb9sdU' (length=10)
      private 'createdAt' => 
        object(DateTime)[40]
          public 'date' => string '2015-06-10 01:13:05' (length=19)
          public 'timezone_type' => int 2
          public 'timezone' => string 'Z' (length=1)
      private 'updatedAt' => 
        object(DateTime)[41]
          public 'date' => string '2015-06-13 13:34:07' (length=19)
          public 'timezone_type' => int 2
          public 'timezone' => string 'Z' (length=1)
      private 'hasBeenFetched' => boolean false
  4 => 
    object(Parse\ParseObject)[48]
      protected 'serverData' => 
        array (size=1)
          'Usuario_FK' => 
            object(Parse\ParseUser)[51]
              ...
      protected 'operationSet' => 
        array (size=0)
          empty
      private 'estimatedData' => 
        array (size=1)
          'Usuario_FK' => 
            object(Parse\ParseUser)[51]
              ...
      private 'dataAvailability' => 
        array (size=1)
          'Usuario_FK' => boolean true
      private 'className' => string 'Asistencia' (length=10)
      private 'objectId' => string 'LRsOGB7mjZ' (length=10)
      private 'createdAt' => 
        object(DateTime)[49]
          public 'date' => string '2015-06-10 03:13:36' (length=19)
          public 'timezone_type' => int 2
          public 'timezone' => string 'Z' (length=1)
      private 'updatedAt' => 
        object(DateTime)[50]
          public 'date' => string '2015-06-13 14:01:03' (length=19)
          public 'timezone_type' => int 2
          public 'timezone' => string 'Z' (length=1)
      private 'hasBeenFetched' => boolean false

      

And then after json_encode ($ results);

[{},{},{},{},{}]

      

Ideas?

Thank you for your time!

+3


source to share





All Articles