function getSerializedIndex($index, $raw = 0)
{
$r = '';
$nl = "\n";
foreach ($index as $s => $ps) {
$r .= $r ? ',' . $nl . $nl : '';
$r .= ' { ' . $nl . ' "@id" : ' . $this->getTerm($s);
//$first_p = 1;
foreach ($ps as $p => $os) {
$r .= ',' . $nl;
$r .= ' ' . $this->getTerm($p) . ' : [';
$first_o = 1;
if (!is_array($os)) {
/* single literal o */
$os = array(array('value' => $os, 'type' => 'literal'));
}
foreach ($os as $o) {
$r .= $first_o ? $nl : ',' . $nl;
$r .= ' ' . $this->getTerm($o, 'o');
$first_o = 0;
}
$r .= $nl . ' ]';
}
$r .= $nl . ' }';
}
$r .= $r ? ' ' : '';
return '[' . $nl . $r . $nl . ']';
}