lib/middleware/lrdd.js
function serializeToJRD(descriptor) {
  var obj = {};
  if (descriptor.expires) { obj.expires = xsdDateTimeString(descriptor.expires); }
  if (descriptor.subject) { obj.subject = descriptor.subject; }
  if (descriptor.aliases.length > 0) {
    obj.aliases = [];
    descriptor.aliases.forEach(function(alias) {
      obj.aliases.push(alias);
    });
  }
  
  if (descriptor.properties.length > 0) {
    obj.properties = {};
    descriptor.properties.forEach(function(key, value) {
      obj.properties[key] = value;
    }, { flatten: true });
  }
  
  if (descriptor.links.length > 0) {
    obj.links = [];
    descriptor.links.forEach(function(link) {
      var l = {};
      if (link.rel) { l.rel = link.rel; }
      if (link.href) { l.href = link.href; }
      if (link.template) { l.template = link.template; }
      if (link.type) { l.type = link.type; }
      
      if (link.titles.length > 0) {
        l.titles = {};
        link.titles.forEach(function(lang, title) {
          if (lang === '_') {
            l.titles['default'] = title;
          } else {
            l.titles[lang] = title;
          }
        }, { flatten: true });
      }
      
      if (link.properties.length > 0) {
        l.properties = {};
        link.properties.forEach(function(key, value) {
          l.properties[key] = value;
        }, { flatten: true });
      }
      
      obj.links.push(l);
    });
  }
  
  return JSON.stringify(obj);
}
function serializeToJRD(descriptor) {
  var obj = {};
  if (descriptor.expires) { obj.expires = xsdDateTimeString(descriptor.expires); }
  if (descriptor.subject) { obj.subject = descriptor.subject; }
  if (descriptor.aliases.length > 0) {
    obj.aliases = [];
    descriptor.aliases.forEach(function(alias) {
      obj.aliases.push(alias);
    });
  }
  
  if (descriptor.properties.length > 0) {
    obj.properties = {};
    descriptor.properties.forEach(function(key, value) {
      obj.properties[key] = value;
    }, { flatten: true });
  }
  
  if (descriptor.links.length > 0) {
    obj.links = [];
    descriptor.links.forEach(function(link) {
      var l = {};
      if (link.rel) { l.rel = link.rel; }
      if (link.href) { l.href = link.href; }
      if (link.template) { l.template = link.template; }
      if (link.type) { l.type = link.type; }
      
      if (link.titles.length > 0) {
        l.titles = {};
        link.titles.forEach(function(lang, title) {
          if (lang === '_') {
            l.titles['default'] = title;
          } else {
            l.titles[lang] = title;
          }
        }, { flatten: true });
      }
      
      if (link.properties.length > 0) {
        l.properties = {};
        link.properties.forEach(function(key, value) {
          l.properties[key] = value;
        }, { flatten: true });
      }
      
      obj.links.push(l);
    });
  }
  
  return JSON.stringify(obj);
}
function serializeToJRD ( descriptor ) { var obj = { } ; if ( descriptor . expires ) { obj . expires = xsdDateTimeString ( descriptor . expires ) ; } if ( descriptor . subject ) { obj . subject = descriptor . subject ; } if ( descriptor . aliases . length > 0 ) { obj . aliases = [ ] ; descriptor . aliases . forEach ( function ( alias ) { obj . aliases . push ( alias ) ; } ) ; } if ( descriptor . properties . length > 0 ) { obj . properties = { } ; descriptor . properties . forEach ( function ( key , value ) { obj . properties [ key ] = value ; } , { flatten : true } ) ; } if ( descriptor . links . length > 0 ) { obj . links = [ ] ; descriptor . links . forEach ( function ( link ) { var l = { } ; if ( link . rel ) { l . rel = link . rel ; } if ( link . href ) { l . href = link . href ; } if ( link . template ) { l . template = link . template ; } if ( link . type ) { l . type = link . type ; } if ( link . titles . length > 0 ) { l . titles = { } ; link . titles . forEach ( function ( lang , title ) { if ( lang === '_' ) { l . titles [ 'default' ] = title ; } else { l . titles [ lang ] = title ; } } , { flatten : true } ) ; } if ( link . properties . length > 0 ) { l . properties = { } ; link . properties . forEach ( function ( key , value ) { l . properties [ key ] = value ; } , { flatten : true } ) ; } obj . links . push ( l ) ; } ) ; } return JSON . stringify ( obj ) ; }
Serialize `descriptor` to JRD format.

@param {Descriptor} descriptor
@return {String}
@api private
Serialize descriptor to JRD format .