Removed JSON output from relation serializations.

This commit is contained in:
Dave Longley 2011-08-02 23:54:19 -04:00
parent 5244670fdb
commit a2924c8d2d

View file

@ -1895,30 +1895,62 @@ class JsonLdProcessor
{ {
$rval = ''; $rval = '';
$first = true;
foreach($b as $p => $o) foreach($b as $p => $o)
{ {
if($p !== '@subject') if($p !== '@subject')
{ {
$first = true; if($first)
{
$first = false;
}
else
{
$rval .= '|';
}
// property
$rval .= '<' . $p . '>';
// object(s)
$objs = is_array($o) ? $o : array($o); $objs = is_array($o) ? $o : array($o);
foreach($objs as $obj) foreach($objs as $obj)
{ {
if($first) if(is_object($obj))
{ {
$first = false; // iri
if(property_exists($obj, '@iri'))
{
if(_isBlankNodeIri($obj->{'@iri'}))
{
$rval .= '_:';
}
else
{
$rval .= '<' . $obj->{'@iri'} . '>';
}
}
// literal
else
{
$rval .= '"' . $obj->{'@literal'} . '"';
// datatype literal
if(property_exists($obj, '@datatype'))
{
$rval .= '^^<' . $obj->{'@datatype'} . '>';
}
// language literal
else if(property_exists($obj, '@language'))
{
$rval .= '@' . $obj->{'@language'};
}
}
} }
// plain literal
else else
{ {
$rval .= '|'; $rval .= '"' . $obj . '"';
}
if(is_object($obj) and property_exists($obj, '@iri') and
_isBlankNodeIri($obj->{'@iri'}))
{
$rval .= '_:';
}
else
{
$rval .= str_replace('\\/', '/', json_encode($obj));
} }
} }
} }
@ -1967,10 +1999,10 @@ class JsonLdProcessor
$b = $this->subjects->$iri; $b = $this->subjects->$iri;
// serialize properties // serialize properties
$s .= '<' . $this->serializeProperties($b) . '>'; $s .= '[' . $this->serializeProperties($b) . ']';
// serialize references // serialize references
$s .= '<'; $s .= '[';
$first = true; $first = true;
$refs = $this->edges->refs->$iri->all; $refs = $this->edges->refs->$iri->all;
foreach($refs as $r) foreach($refs as $r)
@ -1983,9 +2015,11 @@ class JsonLdProcessor
{ {
$s .= '|'; $s .= '|';
} }
$s .= _isBlankNodeIri($r->s) ? '_:' : $refs->s; $s .= '<' . $r->p . '>';
$s .= _isBlankNodeIri($r->s) ?
'_:' : ('<' . $refs->s . '>');
} }
$s .= '>'; $s .= ']';
} }
// serialize adjacent node keys // serialize adjacent node keys