lib/transcode.js
function stringJSON2JSON (doc, compact = false) {
  if (!doc || (typeof doc !== 'string' && typeof doc !== 'object')) {
    throw new TypeError('Argument must be a string or object, and not empty: ' + doc)
  }

  let obj = doc
  if (typeof doc === 'string') {
    obj = JSON.parse(doc)
  }

  return JSON.stringify(obj, undefined, compact ? undefined : 2)
}
function stringJSON2JSON (doc, compact = false) {
  if (!doc || (typeof doc !== 'string' && typeof doc !== 'object')) {
    throw new TypeError('Argument must be a string or object, and not empty: ' + doc)
  }

  let obj = doc
  if (typeof doc === 'string') {
    obj = JSON.parse(doc)
  }

  return JSON.stringify(obj, undefined, compact ? undefined : 2)
}
function stringJSON2JSON ( doc , compact = false ) { if ( ! doc || ( typeof doc !== 'string' && typeof doc !== 'object' ) ) { throw new TypeError ( 'Argument must be a string or object, and not empty: ' + doc ) } let obj = doc if ( typeof doc === 'string' ) { obj = JSON . parse ( doc ) } return JSON . stringify ( obj , undefined , compact ? undefined : 2 ) }
Transcode JSON to JSON string.

@param {string|Object} doc
@param {boolean} [compact]
@return {string}
@api public
Transcode JSON to JSON string .