core/lib/engine_util.js
function extractJSONPath(doc, expr) {
  // typeof null is 'object' hence the explicit check here
  if (typeof doc !== 'object' || doc === null) {
    return '';
  }

  let results;

  try {
    results = jsonpath.query(doc, expr);
  } catch (queryErr) {
    debug(queryErr);
  }

  if (!results) {
    return '';
  }

  if (results.length > 1) {
    return results[randomInt(0, results.length - 1)];
  } else {
    return results[0];
  }
}
function extractJSONPath(doc, expr) {
  // typeof null is 'object' hence the explicit check here
  if (typeof doc !== 'object' || doc === null) {
    return '';
  }

  let results;

  try {
    results = jsonpath.query(doc, expr);
  } catch (queryErr) {
    debug(queryErr);
  }

  if (!results) {
    return '';
  }

  if (results.length > 1) {
    return results[randomInt(0, results.length - 1)];
  } else {
    return results[0];
  }
}
function extractJSONPath ( doc , expr ) { // typeof null is 'object' hence the explicit check here if ( typeof doc !== 'object' || doc === null ) { return '' ; } let results ; try { results = jsonpath . query ( doc , expr ) ; } catch ( queryErr ) { debug ( queryErr ) ; } if ( ! results ) { return '' ; } if ( results . length > 1 ) { return results [ randomInt ( 0 , results . length - 1 ) ] ; } else { return results [ 0 ] ; } }
doc is a JSON object
doc is a JSON object