0

I've got this object. This is the var_dump of my object:

object(stdClass)#2 (3) {
  ["status"]=>
  bool(true)
  ["sql"]=>
  string(122) "SELECT * FROM `story`"
  ["story"]=>
  array(12) {
    ["id"]=>
    string(1) "1"
    ["user_id"]=>
    string(1) "1"
    ["gb_id"]=>
    string(12) "tYQz0zq5-DQC"
    ["date"]=>
    string(19) "0000-00-00 00:00:00"
    ["title"]=>
    string(14) "1893.21.04-148"
    ["story"]=>
    string(4026) "<TEXTFORMAT LEADING="2"><P>HTML STUFF</P></TEXTFORMAT>"
    ["image"]=>
    NULL
    ["views"]=>
    string(1) "1"
    ["username"]=>
    string(9) "username"
    ["password"]=>
    string(6) "789456"
    ["email"]=>
    string(7) "email"
    ["story_id"]=>
    string(1) "3"
  }
}

But when I try to json_encode it, it returns nothing. Does anyone have an idea why?

Has it anything to do with the fact that it could be to big? (Because a left out some big chunks of data above )

8
  • stdClass is probably not encodable. Where is this coming from? If it's the return value of a json_decode, pass true as the second parameter to get an array instead of an object. Commented Aug 15, 2014 at 13:52
  • json_encode cannot return NULL, it can only return a string or boolean FALSE. If it returns FALSE there was an error. Commented Aug 15, 2014 at 13:53
  • 6
    After you call to json_encode, make a call to json_last_error and check its return value here: php.net/manual/en/function.json-last-error.php Commented Aug 15, 2014 at 13:54
  • It returns nothing? Or you just haven't prefaced it with an echo statement, and therefore aren't getting any output? Commented Aug 15, 2014 at 13:54
  • 1
    An stdClass is encodebale. The problem is utf-8 formatting. Thanks guys! Commented Aug 15, 2014 at 14:05

0

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.