I've tried this many times now, using difference methods and none of them have worked for me, so I'm asking this question.

I have a small form that takes in 4 pieces of information, a persons title, first name, middle name and last name. When I hit a button, a JSON Object is formed, and sent as post data through a jQuery.ajax method.

JSON Sent to PHP file:

```
{
    "title": "Mr", 
    "firstName":"Banana",
    "middleName":"Slippy",
    "lastName":"McDougle"
}

```

Ajax call on button press:

```
    function insertPerson(obj, callback){
        $.ajax({
            type: "POST",
            data: "json=" + JSON.stringify(obj),
            url: "insertData.php",
            success: function(obj){
                if (callback){ callback(obj) };
            },
            error: function(error){
                console.log("Error:");
                console.log(error);
            }
        });
    }

```

I pass in a Javascript Object that is then stringyfied and posted as a parameter name 'json'.

In my php file I assign the posted string to a variable, name $json, I then decode using json\_decode(), do some funky business, and send a response back to the browser.

insertData.php:

```
require ('connect.php');
header('Content-type: application/json');

$json_string = $_POST['json'];
$json = json_decode($json_string);
...do server related inserts/selects etc...
echo json_encode($json->title);

```

At the moment I just want to return the title property of the json object that was sent in the post request, but anything I return comes back as null. If I echo back the string, without decoding it, then I get the following:

```
{\"title\":\"Mr\",\"firstName\":\"Banana\",\"middleName\":\"Slippy\",\"lastName\":\"McDougle\"}

```

If I try to extract values using:
 $title = $json->title;
and put that into a MYSQL statement, it's inserted as null or blank, nothing gets input.

Am I doing something wrong? Or have I somehow got an outdated version of PHP to handle JSON? And help is greatly appreciated.