Fixed built-in json number/bool check.

This commit is contained in:
Dave Longley 2011-07-18 16:22:57 -04:00
parent fd37e95a19
commit 1e79de1c41
1 changed files with 11 additions and 10 deletions

View File

@ -912,13 +912,14 @@ function _expand($ctx, $property, $value, $expandSubjects)
$coerce = _getCoerceType($ctx, $property, null); $coerce = _getCoerceType($ctx, $property, null);
// automatic coercion for basic JSON types // automatic coercion for basic JSON types
if($coerce === null and (is_numeric($value) or is_bool($value))) if($coerce === null and !is_string($value) &&
(is_numeric($value) or is_bool($value)))
{ {
if(is_bool($value)) if(is_bool($value))
{ {
$coerce = JSONLD_XSD_BOOLEAN; $coerce = JSONLD_XSD_BOOLEAN;
} }
else if(strpos('' . $value, '.') === false) else if(is_int($value))
{ {
$coerce = JSONLD_XSD_INTEGER; $coerce = JSONLD_XSD_INTEGER;
} }
@ -1873,15 +1874,15 @@ class JsonLdProcessor
/** /**
* Serializes the properties of the given bnode for its relation * Serializes the properties of the given bnode for its relation
* serialization. * serialization.
* *
* @param b the blank node. * @param b the blank node.
* *
* @return the serialized properties. * @return the serialized properties.
*/ */
public function serializeProperties($b) public function serializeProperties($b)
{ {
$rval = ''; $rval = '';
foreach($b as $p => $o) foreach($b as $p => $o)
{ {
if($p !== '@subject') if($p !== '@subject')
@ -1910,7 +1911,7 @@ class JsonLdProcessor
} }
} }
} }
return $rval; return $rval;
} }
@ -1932,7 +1933,7 @@ class JsonLdProcessor
{ {
break; break;
} }
if(isset($done->$k)) if(isset($done->$k))
{ {
// mark cycle // mark cycle
@ -1949,12 +1950,12 @@ class JsonLdProcessor
if(isset($this->subjects->$iri)) if(isset($this->subjects->$iri))
{ {
$b = $this->subjects->$iri; $b = $this->subjects->$iri;
// serialize properties // serialize properties
$rval .= '<'; $rval .= '<';
$rval .= $this->serializeProperties($b); $rval .= $this->serializeProperties($b);
$rval .= '>'; $rval .= '>';
// serialize references // serialize references
$rval .= '<'; $rval .= '<';
$first = true; $first = true;
@ -1974,7 +1975,7 @@ class JsonLdProcessor
$rval .= '>'; $rval .= '>';
} }
} }
$rval .= $this->recursiveSerializeMapping($tmp->k, $output, $done); $rval .= $this->recursiveSerializeMapping($tmp->k, $output, $done);
} }
} }