4 ms·
Okay I made one with javascript ( go to https://underscorejs.org/ https://underscorejs.org/ and open console ) var json = JSON.parse('{"my": "json"}'); (funct
by danschumann 7y ago
Okay I made one with javascript ( go to https://underscorejs.org/ https://underscorejs.org/ and open console )
var json = JSON.parse('{"my": "json"}');
(function printRecursively(ob, _keys = []){
_.map(ob, (val, key) => {
var k = _.isNumber(key) ? '[' + key + ']' : '.' + key;
var keys = _keys.concat(k);
if (_.isObject(val))
printRecursively(val, keys);
else
console.log(keys.join('') + ' = ' + typeof val + ' ' + val);
});
})(json);
EDIT: how do I markup code on HN?
- ComputerGuru 7y ago> how do I markup code Indent each line with four spaces. Please please keep line length very short (under forty?) as HN's pre tags are absolutely not mobile friendly and can trash the entire page. Edit: actually it seems to at least scroll within the comment div on overflow now, that's a huge improvement!