通过多维数组生成JSON

I need to recreate this by pulling it all together in PHP:

 {
  "content": [
    {
      "type": "text/plain",
      "value": " "
    }
  ],
  "from": {
    "email": "dx@sendgrid.com",
    "name": "Ryan Smith"
  },
  "personalizations": [
    {
      "to": [
        {
          "email": "elmer@sendgrid.com"
        }
      ]
    }
  ],
  "subject": "my subject"
}

This is what I have, but it's not quite right:

$content ='some long string';
$to =array('email'=>'elmer@sendgrid.com');

$objectArray = array(
    'content'=> array ('type'=>'text/html', 'value'=>$content),
    'from'=>array('from'=>'dx@sendgrid.com','name'=>'Ryan Smith'),
    'subject'=>'my subject',
    'personalizations'=> array('to'=>$to)
    );
$postfields = json_encode($objectArray);

EDIT

Sorry clicked too soon.

Here's the error that's returned:

{
    "errors": [
        {
            "message": "Invalid type. Expected: array, given: object.",
            "field": "content",
            "help": "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content"
        },
        {
            "message": "Invalid type. Expected: array, given: object.",
            "field": "personalizations",
            "help": "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#-Personalizations-Errors"
        }
    ]
}

What am I doing wrong here?