website-to-json
website-to-json copied to clipboard
Deep arrays?
Is it possible to build deep arrays like so?
{
"data": {
"title": "crawler vs scraper",
"products": [
"123": [
"name": "running shoe",
],
"456": [
"name": "climbing shoe",
]
]
}
}
If so, could you provide some example code? Thanks!
Hello @drewbaker. Yes, it's possible.
You can use jquery .map to get values from DOM:
// very simple example
$('.list').map(function(val) {
return {
id: $(this).find('.id').text(),
name: $(this).find('.name').text()
}
})
And later transform that with lodash mapKeys https://lodash.com/docs/4.17.4#mapKeys