index.js
//Generate json object from plain jt400 response and structure
Generate json object from plain jt400 response and structure
Generate json object from plain jt400 response and structure
generateDataObjectFromStructAndObject(struct, obj) {
		var res={};
		for (var i = 0 ; i < struct.length ; i++) {
			if(struct[i].type == "text") {
				res[struct[i].name]=obj[i].trim();
			} else if(struct[i].type == "bin4") {
				res[struct[i].name]=parseInt(obj[i]);
			} else if(struct[i].type == "zoned" || struct[i].type == "packed") {
				res[struct[i].name]=new BigNumber(obj[i]).toFixed(struct[i].precision).padStart(struct[i].size, "0");
			} 
		}
		return res;
	}
generateDataObjectFromStructAndObject ( struct , obj ) { var res = { } ; for ( var i = 0 ; i < struct . length ; i ++ ) { if ( struct [ i ] . type == "text" ) { res [ struct [ i ] . name ] = obj [ i ] . trim ( ) ; } else if ( struct [ i ] . type == "bin4" ) { res [ struct [ i ] . name ] = parseInt ( obj [ i ] ) ; } else if ( struct [ i ] . type == "zoned" || struct [ i ] . type == "packed" ) { res [ struct [ i ] . name ] = new BigNumber ( obj [ i ] ) . toFixed ( struct [ i ] . precision ) . padStart ( struct [ i ] . size , "0" ) ; } } return res ; }
Generate json object from plain jt400 response and structure
Generate json object from plain jt400 response and structure