79752568

Date: 2025-09-01 13:23:04
Score: 1.5
Natty:
Report link

I finally found a way to do that. Thanks to Rajeev KR answer which drive me to the solution

The hostArray string has to be converted to JSON and it can be done using with a type conversion to json https://github.com/karatelabs/karate#type-conversion

# sample of hostsArray 
* def hostsArray = '[{"hostid": "1234"},{"hostid": "4567"}, {"hostid": "9865"}]'
* json hostArrayJson = hostsArray

* def myjson =
"""
{
  "key1": "val1",
  "params" : {
     "key2": "val2",
     "hosts" : '#(hostsArrayJson)'
  }
"""

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: gerfred