src/jsonpointer.js
function getPointedValue(target, opt_pointer) {
    // .get() method implementation.

    // First argument must be either string or object.
    if (isString(target)) {

      // If string it must be valid JSON document.
      try {
        // Let's try to parse it as JSON.
        target = JSON.parse(target);
      }
      catch (e) {
        // If parsing failed, an exception will be thrown.
        throw getError(ErrorMessage.INVALID_DOCUMENT);
      }
    }
    else if (!isObject(target)) {
      // If not object or string, an exception will be thrown.
      throw getError(ErrorMessage.INVALID_DOCUMENT_TYPE);
    }

    // |target| is already parsed, let's create evaluator function for it.
    var evaluator = createPointerEvaluator(target);

    if (isUndefined(opt_pointer)) {
      // If pointer was not provided, return evaluator function.
      return evaluator;
    }
    else {
      // If pointer is provided, return evaluation result.
      return evaluator(opt_pointer);
    }
  }
function getPointedValue(target, opt_pointer) {
    // .get() method implementation.

    // First argument must be either string or object.
    if (isString(target)) {

      // If string it must be valid JSON document.
      try {
        // Let's try to parse it as JSON.
        target = JSON.parse(target);
      }
      catch (e) {
        // If parsing failed, an exception will be thrown.
        throw getError(ErrorMessage.INVALID_DOCUMENT);
      }
    }
    else if (!isObject(target)) {
      // If not object or string, an exception will be thrown.
      throw getError(ErrorMessage.INVALID_DOCUMENT_TYPE);
    }

    // |target| is already parsed, let's create evaluator function for it.
    var evaluator = createPointerEvaluator(target);

    if (isUndefined(opt_pointer)) {
      // If pointer was not provided, return evaluator function.
      return evaluator;
    }
    else {
      // If pointer is provided, return evaluation result.
      return evaluator(opt_pointer);
    }
  }
function getPointedValue ( target , opt_pointer ) { // .get() method implementation. // First argument must be either string or object. if ( isString ( target ) ) { // If string it must be valid JSON document. try { // Let's try to parse it as JSON. target = JSON . parse ( target ) ; } catch ( e ) { // If parsing failed, an exception will be thrown. throw getError ( ErrorMessage . INVALID_DOCUMENT ) ; } } else if ( ! isObject ( target ) ) { // If not object or string, an exception will be thrown. throw getError ( ErrorMessage . INVALID_DOCUMENT_TYPE ) ; } // |target| is already parsed, let's create evaluator function for it. var evaluator = createPointerEvaluator ( target ) ; if ( isUndefined ( opt_pointer ) ) { // If pointer was not provided, return evaluator function. return evaluator ; } else { // If pointer is provided, return evaluation result. return evaluator ( opt_pointer ) ; } }
Returns |target| object's value pointed by |opt_pointer|, returns undefined
if |opt_pointer| points to non-existing value.
If pointer is not provided, validates first argument and returns
evaluator function that takes pointer as argument.
@param {(string|Object|Array)} target Evaluation target.
@param {string=} opt_pointer JSON Pointer string.
@returns {*} Some value.
Returns |target| object s value pointed by |opt_pointer| returns undefined if |opt_pointer| points to non - existing value . If pointer is not provided validates first argument and returns evaluator function that takes pointer as argument .