protected function _RDFToObject($o, $use_native_types) {
    // convert IRI/blank node object to JSON-LD
    if($o->type === 'IRI' || $o->type === 'blank node') {
      return (object)array('@id' => $o->value);
    }

    // convert literal object to JSON-LD
    $rval = (object)array('@value' => $o->value);

    if(property_exists($o, 'language')) {
      // add language
      $rval->{'@language'} = $o->language;
    } else {
      // add datatype
      $type = $o->datatype;
      // use native types for certain xsd types
      if($use_native_types) {
        if($type === self::XSD_BOOLEAN) {
          if($rval->{'@value'} === 'true') {
            $rval->{'@value'} = true;
          } else if($rval->{'@value'} === 'false') {
            $rval->{'@value'} = false;
          }
        } else if(is_numeric($rval->{'@value'})) {
          if($type === self::XSD_INTEGER) {
            $i = intval($rval->{'@value'});
            if(strval($i) === $rval->{'@value'}) {
              $rval->{'@value'} = $i;
            }
          } else if($type === self::XSD_DOUBLE) {
            $rval->{'@value'} = doubleval($rval->{'@value'});
          }
        }
        // do not add native type
        if(!in_array($type, array(
          self::XSD_BOOLEAN, self::XSD_INTEGER, self::XSD_DOUBLE,
          self::XSD_STRING))) {
          $rval->{'@type'} = $type;
        }
      } else if($type !== self::XSD_STRING) {
        $rval->{'@type'} = $type;
      }
    }

    return $rval;
  }
protected function _RDFToObject($o, $use_native_types) {
    // convert IRI/blank node object to JSON-LD
    if($o->type === 'IRI' || $o->type === 'blank node') {
      return (object)array('@id' => $o->value);
    }

    // convert literal object to JSON-LD
    $rval = (object)array('@value' => $o->value);

    if(property_exists($o, 'language')) {
      // add language
      $rval->{'@language'} = $o->language;
    } else {
      // add datatype
      $type = $o->datatype;
      // use native types for certain xsd types
      if($use_native_types) {
        if($type === self::XSD_BOOLEAN) {
          if($rval->{'@value'} === 'true') {
            $rval->{'@value'} = true;
          } else if($rval->{'@value'} === 'false') {
            $rval->{'@value'} = false;
          }
        } else if(is_numeric($rval->{'@value'})) {
          if($type === self::XSD_INTEGER) {
            $i = intval($rval->{'@value'});
            if(strval($i) === $rval->{'@value'}) {
              $rval->{'@value'} = $i;
            }
          } else if($type === self::XSD_DOUBLE) {
            $rval->{'@value'} = doubleval($rval->{'@value'});
          }
        }
        // do not add native type
        if(!in_array($type, array(
          self::XSD_BOOLEAN, self::XSD_INTEGER, self::XSD_DOUBLE,
          self::XSD_STRING))) {
          $rval->{'@type'} = $type;
        }
      } else if($type !== self::XSD_STRING) {
        $rval->{'@type'} = $type;
      }
    }

    return $rval;
  }
protected function _RDFToObject ( $ o , $ use_native_types ) { // convert IRI/blank node object to JSON-LD if ( $ o -> type === 'IRI' || $ o -> type === 'blank node' ) { return ( object ) array ( '@id' => $ o -> value ) ; } // convert literal object to JSON-LD $ rval = ( object ) array ( '@value' => $ o -> value ) ; if ( property_exists ( $ o , 'language' ) ) { // add language $ rval -> { '@language' } = $ o -> language ; } else { // add datatype $ type = $ o -> datatype ; // use native types for certain xsd types if ( $ use_native_types ) { if ( $ type === self :: XSD_BOOLEAN ) { if ( $ rval -> { '@value' } === 'true' ) { $ rval -> { '@value' } = true ; } else if ( $ rval -> { '@value' } === 'false' ) { $ rval -> { '@value' } = false ; } } else if ( is_numeric ( $ rval -> { '@value' } ) ) { if ( $ type === self :: XSD_INTEGER ) { $ i = intval ( $ rval -> { '@value' } ) ; if ( strval ( $ i ) === $ rval -> { '@value' } ) { $ rval -> { '@value' } = $ i ; } } else if ( $ type === self :: XSD_DOUBLE ) { $ rval -> { '@value' } = doubleval ( $ rval -> { '@value' } ) ; } } // do not add native type if ( ! in_array ( $ type , array ( self :: XSD_BOOLEAN , self :: XSD_INTEGER , self :: XSD_DOUBLE , self :: XSD_STRING ) ) ) { $ rval -> { '@type' } = $ type ; } } else if ( $ type !== self :: XSD_STRING ) { $ rval -> { '@type' } = $ type ; } } return $ rval ; }
Converts an RDF triple object to a JSON-LD object.

@param stdClass $o the RDF triple object to convert.
@param bool $use_native_types true to output native types, false not to.

@return stdClass the JSON-LD object.
Converts an RDF triple object to a JSON - LD object .