I am developing a web application in PHP 5.6.8 with MySql as database engine. 

In my method to authenticate the User for appropriate credentials i am making a call to the database and retrieved the user object. The function code is :

```
function getBoosterDetails($patientId){
       $dbConnection = new Database();

       $sql = "SELECT * from users where id = :patientId";
       try {
           $db = $dbConnection->getConnection();
           $stmt = $db->prepare($sql);
           $stmt->bindParam("patientId", $patientId);
           $stmt->execute();
           $userDetails = $stmt->fetchAll(PDO::FETCH_OBJ);
           $db = null;
           $_SESSION['userDetails'] = $userDetails;

           echo '{"user": ' . json_encode($userDetails) . '}';

       } catch(PDOException $e) {
           echo '{"error":{"text":'. $e->getMessage() .'}}'; 
       } catch(Exception $e1) {
           echo '{"error11":{"text11":'. $e1->getMessage() .'}}'; 
       } }

```

For any valid input I have been getting the error that object is not valid. I tried Inspecting the userDetails object in Advanced Rest Client Chrome Plugin. What I observe is that while the var dump of the object has teh whole object data the echo of json\_encode has truncation as displayed in the below image. 

![enter image description here][1]

I have setup the Apache & MySql Servers with XAMPP (and also tried with MAMP earlier and met with the same result.) 

```
// this is the var_dump
    stdClass object
(
    [username]  => pavan
    [rolename]  => Patient
    [userid]  => 5
)

//this is the json_encode echo output
{"user": [{"username":"pavan", "rolename":"Patient", "userid":

```

The content is getting truncated when it is json encoded
Could you please help me out resolving this.