/**
 * Created by liutiantian on 2015.12.22.
 */

var ltt = ltt || {};
ltt.api = ltt.api || {};
ltt.api.js = ltt.api.js || {};
ltt.api.js.json = ltt.api.js.json || {};

ltt.api.js.json.fetchData = function(source, path, split) {
    if(source) {
        valid:
            if(path) {
                var ar_path = path.split(split || ".");
                if(ar_path && ar_path.length) {
                    var current = source;
                    for(var i = 0; i < ar_path.length; ++i) {
                        if(current) {
                            current = current[ar_path[i]];
                            continue;
                        }
                        break valid;
                    }
                    return current;
                }
            }
            else {
                return source;
            }
    }
};
