Hola JDEFriends,
On this occasion, I want show how I've got to realize in a simple way transform a orchestrator json with items repeated, in other without items repeteaded output.
We are the following json input:
We can see how are several repeated references. We are use the function "uniq" of json module in JRuby into the Manipulated Ouput of ower orchestrator:
require 'json' def main(orchAttr, input) jsonIn = JSON.parse(input) #Add code here to manipulate JSON output items = jsonIn['ITEMS'] unique_items = items.uniq{|item| item['ShortItemNo']} jsonIn['ITEMS'] = unique_items jsonOut = JSON.generate(jsonIn) return jsonOut end
We get all ITEM nodes, and apply the uniq function, this iterate about all items, and it return the json with the unique items in function of the 'ShortItemNo' attribute.