Handle scalars before objects.

This commit is contained in:
Dave Longley 2013-09-13 13:17:40 -04:00
parent d1501c7c08
commit 12a9ccc9e8

View file

@ -2102,8 +2102,21 @@ class JsonLdProcessor {
return $rval;
}
// recursively expand object
if(is_object($element)) {
if(!is_object($element)) {
// drop top-level scalars that are not in lists
if(!$inside_list &&
($active_property === null ||
$this->_expandIri($active_ctx, $active_property,
array('vocab' => true)) === '@graph')) {
return null;
}
// expand element according to value expansion rules
return $this->_expandValue($active_ctx, $active_property, $element);
}
// recursively expand object:
// if element has a context, process it
if(property_exists($element, '@context')) {
$active_ctx = $this->_processContext(
@ -2437,18 +2450,6 @@ class JsonLdProcessor {
return $rval;
}
// drop top-level scalars that are not in lists
if(!$inside_list &&
($active_property === null ||
$this->_expandIri($active_ctx, $active_property,
array('vocab' => true)) === '@graph')) {
return null;
}
// expand element according to value expansion rules
return $this->_expandValue($active_ctx, $active_property, $element);
}
/**
* Performs JSON-LD flattening.
*