<commit_before>/**
 * Manages column names
 * Zero-based indexes
 * @param row
 * @param namesArray
 * @constructor
 */
function RecordManager(namesArray) {
    this._namesArray = namesArray;
    this._namesToIndexes = this._mapNames();
}

RecordManager.prototype._mapNames = function () {
    var t = this,
        m = {};
    var names = t._namesArray;
    for (var i=0; i < t._namesArray.length; i++) {
        m[String(names[i]).trim()] = i;
    }

    return m;
};

RecordManager.prototype._prepareData = function(data){
    return (data && typeof data === "object") ? JSON.stringify(data) : data;
};

RecordManager.prototype._extractData = function(data){
    return (typeof data === "string" && data[0] in {'{':0 , '[':0}) ? JSON.parse(data) : data;
};


RecordManager.prototype.getColumnIndex = function (fieldName) {
    var t = this;
    if (! fieldName) return null;
    return t._namesToIndexes[String(fieldName).trim()] + 1;
};

RecordManager.prototype.getField = function (fieldName, row) {
    var t = this;<commit_msg>RecordManager: JSON serialization fixed<commit_after>/**
 * Manages column names
 * Zero-based indexes
 * @param row
 * @param namesArray
 * @constructor
 */
function RecordManager(namesArray) {
    this._namesArray = namesArray;
    this._namesToIndexes = this._mapNames();
}

RecordManager.prototype._mapNames = function () {
    var t = this,
        m = {};
    var names = t._namesArray;
    for (var i=0; i < t._namesArray.length; i++) {
        m[String(names[i]).trim()] = i;
    }

    return m;
};

RecordManager.prototype._prepareData = function(data){
    return (data && typeof data === "object") ? ('#JSON#:' + JSON.stringify(data)) : data;
};

RecordManager.prototype._extractData = function(data){
    return (typeof data === "string" && data.indexOf('#JSON#:') === 0) ? 
        JSON.parse(data.replace('#JSON#:', '')) : data;
};


RecordManager.prototype.getColumnIndex = function (fieldName) {
    var t = this;
    if (! fieldName) return null;
    return t._namesToIndexes[String(fieldName).trim()] + 1;
};

RecordManager.prototype.getField = function (fieldName, row) {
    var t = this;
{'fraction_non_alphanumeric': 0.16052263182454504, 'fraction_numerical': 0.003733084461035931, 'mean_word_length': 3.6008583690987126, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4105349', 'n_tokens_mistral': 679, 'n_tokens_neox': 669, 'n_words': 155}