<commit_before>'use strict';

module.exports = function(req, res, next){

    // save a pointer to the original res.json() so we can replace it if we don't have a links param
    var originalJson = res.json;

    // override default express res.json method to intercept second param
    res.json = function(object, links){

        // grab the object and avoid updating reference.
        var jsonObject = Object.assign({}, object);

        // set the json function back to its original value (we need to do this so the app instance is correct)
        res.json = originalJson;

        if (!links || links.length<=0){

            // no links provided, therefore process this as normal
            res.json(jsonObject);
        }
        else{

            // either add to existing links collection or add new collection
            jsonObject.links = (jsonObject.links) ? jsonObject.links.concat(links) : jsonObject.links = links;<commit_msg>replaces Object.assign with JSON string parsing to resolve serialisation of array issue<commit_after>'use strict';

module.exports = function(req, res, next){

    // save a pointer to the original res.json() so we can replace it if we don't have a links param
    var originalJson = res.json;

    // override default express res.json method to intercept second param
    res.json = function(object, links){

        // grab the object and avoid updating reference.
        var jsonObject = JSON.parse(JSON.stringify(object));

        // set the json function back to its original value (we need to do this so the app instance is correct)
        res.json = originalJson;

        if (!links || links.length<=0){

            // no links provided, therefore process this as normal
            res.json(jsonObject);
        }
        else{

            // either add to existing links collection or add new collection
            jsonObject.links = (jsonObject.links) ? jsonObject.links.concat(links) : jsonObject.links = links;
{'fraction_non_alphanumeric': 0.08455696202531646, 'fraction_numerical': 0.0010126582278481013, 'mean_word_length': 2.547576301615799, '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': '5974410', 'n_tokens_mistral': 497, 'n_tokens_neox': 475, 'n_words': 211}