From dbd83f15351ae8dd16c53b4c287bc9c1c68f3562 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Fri, 29 Jul 2011 16:02:58 -0400 Subject: [PATCH] Fixes to pass property CURIE conflict during compact. --- jsonld.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jsonld.php b/jsonld.php index 11152f4..b69ef34 100644 --- a/jsonld.php +++ b/jsonld.php @@ -690,7 +690,9 @@ function _compact($ctx, $property, $value, $usedCtx) if($value === null) { + // return null, but check coerce type to add to usedCtx $rval = null; + _getCoerceType($ctx, $property, $usedCtx); } else if(is_array($value)) { @@ -721,10 +723,13 @@ function _compact($ctx, $property, $value, $usedCtx) { if($v !== '@context') { - // set object to compacted property - _setProperty( - $rval, _compactIri($ctx, $key, $usedCtx), - _compact($ctx, $key, $v, $usedCtx)); + // set object to compacted property, only overwrite existing + // properties if the property actually compacted + $p = _compactIri($ctx, $key, $usedCtx); + if($p !== $key or !property_exists($rval, $p)) + { + $rval->$p = _compact($ctx, $key, $v, $usedCtx); + } } } }