# Custom Module Return array of objects

**URL:** <https://forum.inductiveautomation.com/t/custom-module-return-array-of-objects/36738>\
**Category:** Module Development\
**Tags:** perspective, ignition80\
**Created:** [July 15, 2020, 7:09pm UTC](https://forum.inductiveautomation.com/t/custom-module-return-array-of-objects/36738 "2020-07-15T19:09:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jvisser](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@jvisser](https://forum.inductiveautomation.com/u/jvisser)\
**Post date:** [July 15, 2020, 7:09pm UTC](https://forum.inductiveautomation.com/t/custom-module-return-array-of-objects/36738/1 "2020-07-15T19:09:32Z")

</div>

Hi All,

I am trying to build a java module for ignition and have run into an issue. I would like to send back data to populate a drop down which is an array of objects [{‘value’:‘example’,‘label’:example},{…},…]. Right now I have it working but inside a script I am forced to write:

```auto
import ast
self.props.options = []
for category in system.meslite.pdefm.materialcategory.getMaterialCategoriesParentDropdown():
	self.props.options.append(ast.literal_eval(str(vars(category))))

```

My question what is the data type I need to return in my java code to simply write in the script.  
self.props.options = system.meslite.pdefm.materialcategory.getMaterialCategoriesParentDropdown()

Java Code

```auto
@Override
  protected Dict[] getMaterialCategoriesParentDropdownImpl() throws ApiException {
    List<MaterialCategoryDto> materialCategoryDtos = api.getAllMaterialCategories();
    int listSize = materialCategoryDtos.size();
    Dict[] materialCategories = new Dict[listSize];
    for (int i = 0; i<listSize; i++){
      Dict category = new Dict();
      category. __setattr__ (Py.newString("value"),
          Py.newString(Objects.requireNonNull(materialCategoryDtos.get(i).getUid()).toString()));
      category. __setattr__ (Py.newString("label"),Py.newString(
          Objects.requireNonNull(materialCategoryDtos.get(i).getCategoryName())));
      materialCategories[i] = category;
    }
    return materialCategories;
  }

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 15, 2020, 7:42pm UTC](https://forum.inductiveautomation.com/t/custom-module-return-array-of-objects/36738/2 "2020-07-15T19:42:59Z")

</div>

Try returning a `PyStringMap`, or a `PyList` of `PyStringMap`s.

---

<div class="post-metadata">

**Author:** ![jvisser](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@jvisser](https://forum.inductiveautomation.com/u/jvisser)\
**Post date:** [July 15, 2020, 8:13pm UTC](https://forum.inductiveautomation.com/t/custom-module-return-array-of-objects/36738/3 "2020-07-15T20:13:04Z")

</div>

This got me closer however when I set the result of my method to the drop down it is returned as strings instead of objects.

Script to load data

```auto
self.props.options = system.meslite.pdefm.materialcategory.getMaterialCategoriesParentDropdown()

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/e/2e011c35d7c712df19f8ece2e8c004142f5ea645.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 15, 2020, 8:45pm UTC](https://forum.inductiveautomation.com/t/custom-module-return-array-of-objects/36738/4 "2020-07-15T20:45:56Z")

</div>

Whoops. What about a `PyDictionary`, specifically, rather than a `PyStringMap`? I see a bug.

---

<div class="post-metadata">

**Author:** ![jvisser](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@jvisser](https://forum.inductiveautomation.com/u/jvisser)\
**Post date:** [July 15, 2020, 8:52pm UTC](https://forum.inductiveautomation.com/t/custom-module-return-array-of-objects/36738/5 "2020-07-15T20:52:47Z")

</div>

That does the job!

Thank you very much,  
Jordan
