tasks/jsonld/js/jsonld.js
function _objectToRDF(item) {
  var object = {};

  // convert value object to RDF
  if(_isValue(item)) {
    object.type = 'literal';
    var value = item['@value'];
    var datatype = item['@type'] || null;

    // convert to XSD datatypes as appropriate
    if(_isBoolean(value)) {
      object.value = value.toString();
      object.datatype = datatype || XSD_BOOLEAN;
    }
    else if(_isDouble(value) || datatype === XSD_DOUBLE) {
      // canonical double representation
      object.value = value.toExponential(15).replace(/(\d)0*e\+?/, '$1E');
      object.datatype = datatype || XSD_DOUBLE;
    }
    else if(_isNumber(value)) {
      object.value = value.toFixed(0);
      object.datatype = datatype || XSD_INTEGER;
    }
    else if('@language' in item) {
      object.value = value;
      object.datatype = datatype || RDF_LANGSTRING;
      object.language = item['@language'];
    }
    else {
      object.value = value;
      object.datatype = datatype || XSD_STRING;
    }
  }
  // convert string/node object to RDF
  else {
    var id = _isObject(item) ? item['@id'] : item;
    object.type = (id.indexOf('_:') === 0) ? 'blank node' : 'IRI';
    object.value = id;
  }

  return object;
}
function _objectToRDF(item) {
  var object = {};

  // convert value object to RDF
  if(_isValue(item)) {
    object.type = 'literal';
    var value = item['@value'];
    var datatype = item['@type'] || null;

    // convert to XSD datatypes as appropriate
    if(_isBoolean(value)) {
      object.value = value.toString();
      object.datatype = datatype || XSD_BOOLEAN;
    }
    else if(_isDouble(value) || datatype === XSD_DOUBLE) {
      // canonical double representation
      object.value = value.toExponential(15).replace(/(\d)0*e\+?/, '$1E');
      object.datatype = datatype || XSD_DOUBLE;
    }
    else if(_isNumber(value)) {
      object.value = value.toFixed(0);
      object.datatype = datatype || XSD_INTEGER;
    }
    else if('@language' in item) {
      object.value = value;
      object.datatype = datatype || RDF_LANGSTRING;
      object.language = item['@language'];
    }
    else {
      object.value = value;
      object.datatype = datatype || XSD_STRING;
    }
  }
  // convert string/node object to RDF
  else {
    var id = _isObject(item) ? item['@id'] : item;
    object.type = (id.indexOf('_:') === 0) ? 'blank node' : 'IRI';
    object.value = id;
  }

  return object;
}
function _objectToRDF ( item ) { var object = { } ; // convert value object to RDF if ( _isValue ( item ) ) { object . type = 'literal' ; var value = item [ '@value' ] ; var datatype = item [ '@type' ] || null ; // convert to XSD datatypes as appropriate if ( _isBoolean ( value ) ) { object . value = value . toString ( ) ; object . datatype = datatype || XSD_BOOLEAN ; } else if ( _isDouble ( value ) || datatype === XSD_DOUBLE ) { // canonical double representation object . value = value . toExponential ( 15 ) . replace ( / (\d)0*e\+? / , '$1E' ) ; object . datatype = datatype || XSD_DOUBLE ; } else if ( _isNumber ( value ) ) { object . value = value . toFixed ( 0 ) ; object . datatype = datatype || XSD_INTEGER ; } else if ( '@language' in item ) { object . value = value ; object . datatype = datatype || RDF_LANGSTRING ; object . language = item [ '@language' ] ; } else { object . value = value ; object . datatype = datatype || XSD_STRING ; } } // convert string/node object to RDF else { var id = _isObject ( item ) ? item [ '@id' ] : item ; object . type = ( id . indexOf ( '_:' ) === 0 ) ? 'blank node' : 'IRI' ; object . value = id ; } return object ; }
Converts a JSON-LD value object to an RDF literal or a JSON-LD string or
node object to an RDF resource.

@param item the JSON-LD value or node object.

@return the RDF literal or RDF resource.
Converts a JSON - LD value object to an RDF literal or a JSON - LD string or node object to an RDF resource .