'Karate : dynamic test data using scenario outline is not working in some cases

I was tryiny to solve dynamic test data problem using dynamic scenario outline as mentioned in the documentation https://github.com/karatelabs/karate#dynamic-scenario-outline It worked perfectly fine when I passed something like this in Example section

Examples: |[{'entity':country},{'entity':state},{'entity':district},{'entity':corporation}]] But I tried to generate this json object programatically , I am getting aa strange error

WARN com.intuit.karate - ignoring dynamic expression, did not evaluate to list: users - [type: MAP, value: com.intuit.karate.ScriptObjectMap@2b8bb184]

Code to generate json object

    * def user =
    """
      function(response){

        entity_type_ids =[]
        var entityTypes = response.entityTypes
        for(var i =0;i<entityTypes.length;i++ ){
          object = {}
          object['entity'] = entityTypes[i].id
          entity_type_ids.push(object)
        }
        return JSON.stringify(entity_type_ids)
      }
    """


Sources

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

Source: Stack Overflow

Solution Source