Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep arrays? #2

Open
drewbaker opened this issue May 23, 2017 · 1 comment
Open

Deep arrays? #2

drewbaker opened this issue May 23, 2017 · 1 comment

Comments

@drewbaker
Copy link

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!

@cigolpl
Copy link
Member

cigolpl commented Jun 2, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants