jquery-google-sheet-to-json.js
// take a row in googl-ese json and return it as name:value pairs
take a row in googl-ese json and return it as name:value pairs
take a row in googl - ese json and return it as name : value pairs
function rowToObject(cell){
		var returner = {};
		var properties = Object.getOwnPropertyNames(cell);
		properties.sort();
		properties.forEach(function(key){
			var val = cell[key].$t;
			if(val === '') return;
			if(key.substring(0,4) === 'gsx$'){
				var name = key.substr(4);
				var num = name.charAt(name.length - 1);
				if(/^\d+$/.test(num)){ 
					name = name.substr(0, name.length - 1);
					var arr = returner[name];
					if(!Array.isArray(arr)){
						returner[name] = [];
						if(arr) returner[name].push(arr);
					}
					returner[name].push(val);
				} else returner[name] = val; 
			}
		});
		return returner;
	}
function rowToObject ( cell ) { var returner = { } ; var properties = Object . getOwnPropertyNames ( cell ) ; properties . sort ( ) ; properties . forEach ( function ( key ) { var val = cell [ key ] . $t ; if ( val === '' ) return ; if ( key . substring ( 0 , 4 ) === 'gsx$' ) { var name = key . substr ( 4 ) ; var num = name . charAt ( name . length - 1 ) ; if ( / ^\d+$ / . test ( num ) ) { name = name . substr ( 0 , name . length - 1 ) ; var arr = returner [ name ] ; if ( ! Array . isArray ( arr ) ) { returner [ name ] = [ ] ; if ( arr ) returner [ name ] . push ( arr ) ; } returner [ name ] . push ( val ) ; } else returner [ name ] = val ; } } ) ; return returner ; }
take a row in googl-ese json and return it as name:value pairs
take a row in googl - ese json and return it as name : value pairs
// sorting is important for catching numbered properties below // name sure the un-numbered name is first // don't bother with empty values // which also means properties will not be set for empty values! // the only tricky thing is to turn the property value into an array // if the property name has variations that end in a number // Address, Address1, Address2... etc. // indexed propery // if arr is not an array, but exists its the unnumbered value: ex. Address // replace its position with an array and push it in first // the basic case for a name/value pair