Return unique array values from an array inside an array of objects

后端 未结 8 2142
逝去的感伤
逝去的感伤 2021-01-14 16:25

I can\'t find a similar question and I\'m a bit stuck. I have the following JSON array:

[
    {
        \"Name\": \"element1\",
        \"Attributes\": [\"1\         


        
8条回答
  •  [愿得一人]
    2021-01-14 17:12

    If lodash is an option, you can easily get what you want:

    > _.chain(foo).map('Attributes').flatten().uniq().value()
    ["1", "2", "3"]
    

提交回复
热议问题