Add elements to a list through a variable that changes by "for each"

Add elements to a list through a variable that changes by "for each"

Hello.

Please could you help me with the following code?

  1. data1 = map();
  2. data2 = map();
  3. all_data = list();

  4. item = map();
  5. all_items = list();

  6. data1 = {"name":"Jose", "age":"20"};
  7. data2 = {"name":"Maria", "age":"25"};
  8. all_data.add(data1);
  9. all_data.add(data2);
  10. for each i in all_data
  11. {
  12. item.clear();
  13. item.put("type","student");
  14. item.put(i);
  15. all_items.add(item);
  16. }
  17. info all_items;

The output is:
{"type":"student","name":"Maria","age":"25"},{"type":"student","name":"Maria","age":"25"}

But my expectation is as follows:
{"type":"student","name":"Jose","age":"20"},{"type":"student","name":"Maria","age":"25"}

Thank you very much in advance for your help.

José