'Groovy create 2 dim array [][] from string

string = """
name:bla1-service,
  version:Sprint-91.0.0
  
  name:bla2-service,
  version:Sprint-93.0.0
  
  name:cbla3-service,
  version:Sprint-93.0.0
  
  name:bla4-service,
  version:Sprint-93.0.0
  
"""

end result should be an array

myArray = [[bla1-service,version:Sprint-91.0.0],[bla2-service,Sprint-93.0.0] ...]

i can use a for loop to search for string like "name" and "version" and build this but i figure there must be a simpler way (maybe using split(",")?) can anyone suggest a better way?



Sources

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

Source: Stack Overflow

Solution Source