PHP json_encode在数组方括号之前的额外引用

I intend to generate JSON that's like this:

{ "stores": [{"Name":"abc","Phone","1234567"},{"Name":"def","Phone","1111111"}], "numResults": 2 }

My php code is like this:

       while($row = mysql_fetch_assoc($result)){
            $store[] = $row;
            $k++;
       }
       $obj['stores'] = json_encode($store);           
       $obj['numResult'] = $numResult;           
       echo stripslashes(json_encode($obj));

However the result seems to have an extra pair of double quotes around the square brackets:

{ "stores": "[{"Name":"abc","Phone","1234567"},{"Name":"def","Phone","1111111"}]", "numResults": 2 }

How can I remove them? (Or is what's actually showing suppose to be the correct JSON formatting?)

Thanks!

Only convert to JSON one time, once you have the complete object the way you want it:

       while($row = mysql_fetch_assoc($result)){
            $store[] = $row;
            $k++;
       }
       $obj['stores'] = $store; // <---------Note change           
       $obj['numResult'] = $numResult;           
       $myJSONstring = json_encode($obj);

You wont need to json_encode twice. Create your $obj variable and json_encode that once it is completely created.

Simple way would be

$my_string = json_encode($my_json,JSON_FORCE_OBJECT);