var $ = require('jquery');

module.exports = {
	parseJSON(s) {
		var json = s;
		if (typeof s == "string") {
			json = $.parseJSON(data);
		} else if (typeof s == "function") {
			json = s();
		}
		if (!json) return undefined;
		
		switch(json.status) {
			case -11 :
			case -12 :
			case -13 :
				console.log("JSON Request Error.[", json.status, "]");
				top.location.href = json.message;
				return undefined;
			default:
				console.log("JSON Request : [", json.status, "]", json.message);
				break;
		}
		
		return json;
	}
}
