Permalink
Browse files

The default value of useNativeTypes has been changed to false

Even with useNativeTypes set to false, strings will not be typed with xsd:string.

For the moment, both produceGeneralizedRdf and produceGeneralizedRDF are accepted as flag names for the toRDF algorithm. See json-ld/json-ld.org@d6460dc#commitcomment-4015838
  • Loading branch information...
1 parent 75cb1db commit d753aa5a80c7a6e22993b30d11e79d0f99868436 @lanthaler committed Sep 4, 2013
Showing with 12 additions and 6 deletions.
  1. +5 −1 JsonLD.php
  2. +7 −5 TypedValue.php
View
@@ -595,7 +595,7 @@ private static function mergeOptions($options)
'compactArrays' => true,
'optimize' => false,
'graph' => null,
- 'useNativeTypes' => true,
+ 'useNativeTypes' => false,
'useRdfType' => false,
'produceGeneralizedRdf' => false,
'documentFactory' => null
@@ -618,6 +618,10 @@ private static function mergeOptions($options)
} elseif (is_object($options->expandContext)) {
$result->expandContext = $options->expandContext;
}
+
+ if (is_object($result->expandContext) && property_exists($result->expandContext, '@context')) {
+ $result->expandContext = $result->expandContext->{'@context'};
+ }
}
if (property_exists($options, 'compactArrays') && is_bool($options->compactArrays)) {
$result->compactArrays = $options->compactArrays;
View
@@ -83,12 +83,14 @@ public function toJsonLd($useNativeTypes = true)
{
$result = new Object();
- if (true === $useNativeTypes) {
- if (RdfConstants::XSD_STRING === $this->type) {
- $result->{'@value'} = $this->value;
+ if (RdfConstants::XSD_STRING === $this->type) {
+ $result->{'@value'} = $this->value;
+
+ return $result;
+ }
- return $result;
- } elseif (RdfConstants::XSD_BOOLEAN === $this->type) {
+ if (true === $useNativeTypes) {
+ if (RdfConstants::XSD_BOOLEAN === $this->type) {
if ('true' === $this->value) {
$result->{'@value'} = true;

1 comment on commit d753aa5

@lanthaler
Owner

Apparently I forgot to include the code for produceGeneralizedRDF but the JSON-LD test suite has been fixed in the meantime anyway

Please sign in to comment.