const json = JSON.stringify({
time: 'placeholder',
data_a: [11, 22, 33, 44, 55, 66, 77, 88, 99],
data_s: 'some text',
data_n: 1.23456789,
links: {
first: 'http://www.example.com/query?first',
next: 'http://www.example.com/query?next',
prev: 'http://www.example.com/query?prev',
last: 'http://www.example.com/query?last'
}
});
function sameJson() {
return json.replace('placeholder', '123456789');
}
function uniqJson() {
return json.replace('placeholder', '' + Date.now());
}
let result = 0;
function countKeys(obj) {
result += Object.keys(obj).length;
}
function parse1(str) {
countKeys(JSON.parse(str));
}
function parse2(str) {
countKeys((new Function('return ' + str))());
}