'How to convert a list of objects into a simple list, selecting a single attribute from the list of objects?

Suppose we have this:

whitelist = [
  { 
     cidr = "10.0.0.0/8",
     desc = "customer1"
  },
  {
     cidr = "10.1.0.0/8",
     desc = "customer2"
  },...
]

How do I make a simple list whitelist_cidrs which is simply:

whitelist_cidrs = [ "10.0.0.0/8", "0.1.0.0/8",...]

How do I convert a list of objects to a simple list of strings?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source