newdata can be a string or array (preferred)
184626
public static function gradeUpdateJson($newdata=false) {
        global $CFG, $PDOX, $LINK, $RESULT;
        if ( $newdata == false ) return;
        if ( is_string($newdata) ) $newdata = json_decode($newdata, true);
        $LAUNCH = LTIX::requireData(array(LTIX::LINK));
        if ( ! isset($RESULT) ) return;
        $row = self::gradeLoad();
        $data = array();
        if ( $row !== false && isset($row['json'])) {
            $data = json_decode($row['json'], true);
        }

        $changed = false;
        foreach ($newdata as $k => $v ) {
            if ( (!isset($data[$k])) || $data[$k] != $v ) {
                $data[$k] = $v;
                $changed = true;
            }
        }

        if ( $changed === false ) return;

        $jstr = json_encode($data);

        $stmt = $PDOX->queryDie(
            "UPDATE {$CFG->dbprefix}lti_result SET json = :json, updated_at = NOW()
                WHERE result_id = :RID",
            array(
                ':json' => $jstr,
                ':RID' => $RESULT->id)
        );
    }
423424
function () {
    return validateData.apply(this, [this.options,
        undefined].concat(Array.prototype.slice.call(arguments)));
  }
160147
function clone(orig, dataType){
	if(!dataType)
		dataType = getDataType(orig);

	if(dataType == 'Array'){
		var newArray = [];
		for(var i = 0; i < orig.length; i++)
			newArray.push(orig[i]);

		return newArray;

	} else if(dataType == 'Object') {
		var newObject = {};
		for(var key in orig)
			newObject[key] = clone(orig[key]);

		return newObject;

	} else
		return orig;
}
609100
def create_string_array(self, key, value):
        
        data = None
        if key is not None and value is not None:
            if isinstance(value, (list)):
                data = self.db.create(key.strip(), json.dumps(value))
            else:
                # used to save raw value with embedded variables
                data = self.db.create(key.strip(), value)
        else:
            self.tcex.log.warning(u'The key or value field was None.')
        return data
902791
Object[] getNewRowData(Session session) {

        Object[] data = new Object[getColumnCount()];
        int      i;

        if (hasDefaultValues) {
            for (i = 0; i < getColumnCount(); i++) {
                Expression def = colDefaults[i];

                if (def != null) {
                    data[i] = def.getValue(session, colTypes[i]);
                }
            }
        }

        return data;
    }
874253
function __serializeString(data) {
	let dataBuffer = UTF8Encode(data);
	let length = dataBuffer.byteLength;
	let lengthData = new Uint32Array([length]);
	return [lengthData.buffer, dataBuffer];
}
1332024
private String jsonifyData(Map<String, ? extends Object> data) {
        JSONObject jsonData = new JSONObject(data);

        return jsonData.toString();
    }
1191956
function stringify(data, options = {}) {
  const _options$strict = options.strict,
        strict = _options$strict === void 0 ? false : _options$strict;
  return baseFormat(data, strict);
}
86193
function __serializeArray(data, options=DEFAULT_OPTIONS) {
	let dataBuffers = [];
	// ignore undefined value
	for (let key in data) {
		let subData = data[key];
		let subType = __getType(subData, options);
		let subTypeBuffer = __serializeType(subType);
		let subDataBuffers = __serializeData(subType, subData, options);
		dataBuffers.push(subTypeBuffer, ...subDataBuffers);
	}
	let length = __getLengthByArrayBuffers(dataBuffers);
	let lengthData = new Uint32Array([length]);
	return [lengthData.buffer, ...dataBuffers];
}
749021
function(into, data) {
                            var existingDataLen = into.length == 0 ? 0 : into[0].length - 1;
                            var i = 0;
                            var j = 0;
                            for (; i<into.length && j<data.length; ) {
                                if (into[i][0] == data[j][0]) {
                                    into[i].push(data[j][1]);
                                    i++;
                                    j++;
                                }
                                else if (into[i][0] < data[j][0]) {
                                    into[i].push(null);
                                    i++;
                                }
                                else {
                                    var arr = [data[j][0]];
                                    for (var k=1; k<into[i].length; k++) {
                                        arr.push(null);
                                    }
                                    arr.push(data[j][1]);
                                    into.splice(i,0,arr);
                                    i++;
                                    j++;
                                }
                            }
                            while (j<data.length) {
                                var arr = [data[j][0]];
                                for (var k=0; k<existingDataLen; k++) {
                                    arr.push(null);
                                }
                                arr.push(data[j][1]);
                                into.push(arr);
                                j++;
                            }
                        }
1090996
function () {
            var values = this.__opts.values, ret = [];
            if (isArray(values)) {
                ret.push(values.length === 0 ? " DEFAULT VALUES" : " VALUES " + this.literal(values));
            } else if (isInstanceOf(values, Dataset)) {
                ret.push(" " + this._subselectSql(values));
            } else if (isInstanceOf(values, LiteralString)) {
                ret.push(" " + values.toString(this));
            } else {
                throw new QueryError("Unsupported INSERT values type, should be an array or dataset");
            }
            return ret.join("");
        }
544460
function ensureAnArray (arr) {
        if (Object.prototype.toString.call(arr) === '[object Array]') {
            return arr;
        } else if (arr === null || arr === void 0) {
            return [];
        } else {
            return [arr];
        }
    }
417116
private static function prepareData(array $data)
    {
        $newData = [];

        foreach ($data as $paramName => $paramValue) {
            if (is_array($paramValue)) {
                foreach ($paramValue as $newKey => $newValue) {
                    $newData[trim($paramName).'['.trim($newKey).']'] = trim($newValue);
                }
            } else {
                $newData[trim($paramName)] = trim($paramValue);
            }
        }

        return $newData;
    }
419150
private void resizeElementArrays(int dataLength, int newLength) {

        Object temp;
        int    usedLength = newLength > dataLength ? dataLength
                                                   : newLength;

        if (isIntKey) {
            temp        = intKeyTable;
            intKeyTable = new int[newLength];

            System.arraycopy(temp, 0, intKeyTable, 0, usedLength);
        }

        if (isIntValue) {
            temp          = intValueTable;
            intValueTable = new int[newLength];

            System.arraycopy(temp, 0, intValueTable, 0, usedLength);
        }

        if (isLongKey) {
            temp         = longKeyTable;
            longKeyTable = new long[newLength];

            System.arraycopy(temp, 0, longKeyTable, 0, usedLength);
        }

        if (isLongValue) {
            temp           = longValueTable;
            longValueTable = new long[newLength];

            System.arraycopy(temp, 0, longValueTable, 0, usedLength);
        }

        if (isObjectKey) {
            temp           = objectKeyTable;
            objectKeyTable = new Object[newLength];

            System.arraycopy(temp, 0, objectKeyTable, 0, usedLength);
        }

        if (isObjectValue) {
            temp             = objectValueTable;
            objectValueTable = new Object[newLength];

            System.arraycopy(temp, 0, objectValueTable, 0, usedLength);
        }

        if (accessTable != null) {
            temp        = accessTable;
            accessTable = new int[newLength];

            System.arraycopy(temp, 0, accessTable, 0, usedLength);
        }

        if (multiValueTable != null) {
            temp            = multiValueTable;
            multiValueTable = new boolean[newLength];

            System.arraycopy(temp, 0, multiValueTable, 0, usedLength);
        }
    }
326664
function fixdata(data) {
		var o = '',
			l = 0,
			w = 10240;
		for (; l < data.byteLength / w; ++l)
			o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
		o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
		return o;
	}
724560
def new_param(name, type, value, start = None, scale = None, unit = None, dataunit = None, comment = None):
	
	elem = Param()
	elem.Name = name
	elem.Type = type
	elem.pcdata = value
	# FIXME:  I have no idea how most of the attributes should be
	# encoded, I don't even know what they're supposed to be.
	if dataunit is not None:
		elem.DataUnit = dataunit
	if scale is not None:
		elem.Scale = scale
	if start is not None:
		elem.Start = start
	if unit is not None:
		elem.Unit = unit
	if comment is not None:
		elem.appendChild(ligolw.Comment())
		elem.childNodes[-1].pcdata = comment
	return elem
1078302
function createData(id, date, name, shipTo, paymentMethod, amount) {
  return { id, date, name, shipTo, paymentMethod, amount };
}