tasks/jsonld/js/jsonld.js
function _expandValue(activeCtx, activeProperty, value) {
  // nothing to expand
  if(value === null) {
    return null;
  }

  // special-case expand @id and @type (skips '@id' expansion)
  var expandedProperty = _expandIri(activeCtx, activeProperty, {vocab: true});
  if(expandedProperty === '@id') {
    return _expandIri(activeCtx, value, {base: true});
  }
  else if(expandedProperty === '@type') {
    return _expandIri(activeCtx, value, {vocab: true, base: true});
  }

  // get type definition from context
  var type = jsonld.getContextValue(activeCtx, activeProperty, '@type');

  // do @id expansion (automatic for @graph)
  if(type === '@id' || (expandedProperty === '@graph' && _isString(value))) {
    return {'@id': _expandIri(activeCtx, value, {base: true})};
  }
  // do @id expansion w/vocab
  if(type === '@vocab') {
    return {'@id': _expandIri(activeCtx, value, {vocab: true, base: true})};
  }

  // do not expand keyword values
  if(_isKeyword(expandedProperty)) {
    return value;
  }

  rval = {};

  // other type
  if(type !== null) {
    rval['@type'] = type;
  }
  // check for language tagging for strings
  else if(_isString(value)) {
    var language = jsonld.getContextValue(
      activeCtx, activeProperty, '@language');
    if(language !== null) {
      rval['@language'] = language;
    }
  }
  rval['@value'] = value;

  return rval;
}
function _expandValue(activeCtx, activeProperty, value) {
  // nothing to expand
  if(value === null) {
    return null;
  }

  // special-case expand @id and @type (skips '@id' expansion)
  var expandedProperty = _expandIri(activeCtx, activeProperty, {vocab: true});
  if(expandedProperty === '@id') {
    return _expandIri(activeCtx, value, {base: true});
  }
  else if(expandedProperty === '@type') {
    return _expandIri(activeCtx, value, {vocab: true, base: true});
  }

  // get type definition from context
  var type = jsonld.getContextValue(activeCtx, activeProperty, '@type');

  // do @id expansion (automatic for @graph)
  if(type === '@id' || (expandedProperty === '@graph' && _isString(value))) {
    return {'@id': _expandIri(activeCtx, value, {base: true})};
  }
  // do @id expansion w/vocab
  if(type === '@vocab') {
    return {'@id': _expandIri(activeCtx, value, {vocab: true, base: true})};
  }

  // do not expand keyword values
  if(_isKeyword(expandedProperty)) {
    return value;
  }

  rval = {};

  // other type
  if(type !== null) {
    rval['@type'] = type;
  }
  // check for language tagging for strings
  else if(_isString(value)) {
    var language = jsonld.getContextValue(
      activeCtx, activeProperty, '@language');
    if(language !== null) {
      rval['@language'] = language;
    }
  }
  rval['@value'] = value;

  return rval;
}
function _expandValue ( activeCtx , activeProperty , value ) { // nothing to expand if ( value === null ) { return null ; } // special-case expand @id and @type (skips '@id' expansion) var expandedProperty = _expandIri ( activeCtx , activeProperty , { vocab : true } ) ; if ( expandedProperty === '@id' ) { return _expandIri ( activeCtx , value , { base : true } ) ; } else if ( expandedProperty === '@type' ) { return _expandIri ( activeCtx , value , { vocab : true , base : true } ) ; } // get type definition from context var type = jsonld . getContextValue ( activeCtx , activeProperty , '@type' ) ; // do @id expansion (automatic for @graph) if ( type === '@id' || ( expandedProperty === '@graph' && _isString ( value ) ) ) { return { '@id' : _expandIri ( activeCtx , value , { base : true } ) } ; } // do @id expansion w/vocab if ( type === '@vocab' ) { return { '@id' : _expandIri ( activeCtx , value , { vocab : true , base : true } ) } ; } // do not expand keyword values if ( _isKeyword ( expandedProperty ) ) { return value ; } rval = { } ; // other type if ( type !== null ) { rval [ '@type' ] = type ; } // check for language tagging for strings else if ( _isString ( value ) ) { var language = jsonld . getContextValue ( activeCtx , activeProperty , '@language' ) ; if ( language !== null ) { rval [ '@language' ] = language ; } } rval [ '@value' ] = value ; return rval ; }
Expands the given value by using the coercion and keyword rules in the
given context.

@param activeCtx the active context to use.
@param activeProperty the active property the value is associated with.
@param value the value to expand.

@return the expanded value.
Expands the given value by using the coercion and keyword rules in the given context .