lib/utilities.js
function getNodeVaue(path, obj) {
    // Gets a value from a JSON object
    // vcard[0].url[0]
    var output = null;
    try {
        var arrayDots = path.split(".");
        for (var i = 0; i < arrayDots.length; i++) {
            if (arrayDots[i].indexOf('[') > -1) {
                // Reconstructs and adds access to array of objects
                var arrayAB = arrayDots[i].split("[");
                var arrayName = arrayAB[0];
                var arrayPosition = Number(arrayAB[1].substring(0, arrayAB[1].length - 1));

                if (obj[arrayName] != null || obj[arrayName] != 'undefined') {
                    if (obj[arrayName][arrayPosition] != null || obj[arrayName][arrayPosition] != 'undefined')
                        obj = obj[arrayName][arrayPosition];

                }
                else {
                    currentObject = null;
                }

            }
            else {
                // Adds access to a property using property array ["given-name"]
                if (obj[arrayDots[i]] != null || obj[arrayDots[i]] != 'undefined')
                  obj = obj[arrayDots[i]];
            }
        }
        output = obj;
    } catch (err) {
        // Add error capture
        output = null;
    }
    return output;
}
function getNodeVaue(path, obj) {
    // Gets a value from a JSON object
    // vcard[0].url[0]
    var output = null;
    try {
        var arrayDots = path.split(".");
        for (var i = 0; i < arrayDots.length; i++) {
            if (arrayDots[i].indexOf('[') > -1) {
                // Reconstructs and adds access to array of objects
                var arrayAB = arrayDots[i].split("[");
                var arrayName = arrayAB[0];
                var arrayPosition = Number(arrayAB[1].substring(0, arrayAB[1].length - 1));

                if (obj[arrayName] != null || obj[arrayName] != 'undefined') {
                    if (obj[arrayName][arrayPosition] != null || obj[arrayName][arrayPosition] != 'undefined')
                        obj = obj[arrayName][arrayPosition];

                }
                else {
                    currentObject = null;
                }

            }
            else {
                // Adds access to a property using property array ["given-name"]
                if (obj[arrayDots[i]] != null || obj[arrayDots[i]] != 'undefined')
                  obj = obj[arrayDots[i]];
            }
        }
        output = obj;
    } catch (err) {
        // Add error capture
        output = null;
    }
    return output;
}
function getNodeVaue ( path , obj ) { // Gets a value from a JSON object // vcard[0].url[0] var output = null ; try { var arrayDots = path . split ( "." ) ; for ( var i = 0 ; i < arrayDots . length ; i ++ ) { if ( arrayDots [ i ] . indexOf ( '[' ) > - 1 ) { // Reconstructs and adds access to array of objects var arrayAB = arrayDots [ i ] . split ( "[" ) ; var arrayName = arrayAB [ 0 ] ; var arrayPosition = Number ( arrayAB [ 1 ] . substring ( 0 , arrayAB [ 1 ] . length - 1 ) ) ; if ( obj [ arrayName ] != null || obj [ arrayName ] != 'undefined' ) { if ( obj [ arrayName ] [ arrayPosition ] != null || obj [ arrayName ] [ arrayPosition ] != 'undefined' ) obj = obj [ arrayName ] [ arrayPosition ] ; } else { currentObject = null ; } } else { // Adds access to a property using property array ["given-name"] if ( obj [ arrayDots [ i ] ] != null || obj [ arrayDots [ i ] ] != 'undefined' ) obj = obj [ arrayDots [ i ] ] ; } } output = obj ; } catch ( err ) { // Add error capture output = null ; } return output ; }
a helper function, finds a property value of a given object literal
a helper function finds a property value of a given object literal