Parameter formats in the browser

Last modified: May 20, 2009 - 06:43

The browser provides three formats for use with the complex parameter types struct and array. These formats are JSON, serialized PHP and comma-separated values. Comma-separated values are only applicable to the array parameter type.

Json

See http://json.org/ for all the details.

Object notation:

{"title":"Sample node", "type":"page", "uid":1}

This will be unserialized to a object if the parameter type is struct, and a associative array if the parameter type is array.

Array notation:

["mlid","title","href"]

This will be unserialized to an array, regardless of the parameter type.

Comma-separated values

Comma separated values should be written like this:

mlid,title,href

No escaping of commas or quoting of values is possible. mlid,"go, go!",href would be unserialized to array('mlid','"go',' go!"','href'). If you want more advanced parsing - use JSON.

Serialized PHP

Please don't write serialized php by hand, be nice to yourself and use something like the following:

<?php
$arr
= array('mlid','title','href');
print
serialize($arr) . "\n\n";

$obj = (object)array(
 
'title' => 'Sample node',
 
'type' => 'page',
 
'uid' => 1,
);
print
serialize($obj);
?>

This would output the following if run:

a:3:{i:0;s:4:"mlid";i:1;s:5:"title";i:2;s:4:"href";}

O:8:"stdClass":3:{s:5:"title";s:11:"Sample node";s:4:"type";s:4:"page";s:3:"uid";i:1;}

Then you can just copy paste into the parameter text field.

 
 

Drupal is a registered trademark of Dries Buytaert.