Skip to content

Instantly share code, notes, and snippets.

@mattisebastian
mattisebastian / json-slurper.groovy
Created January 31, 2018 13:35
How to extract json in groovy
/*
* The integration developer needs to create the method processData
* This method takes Message object of package com.sap.gateway.ip.core.customdev.util
* which includes helper methods useful for the content developer:
*
* The methods available are:
public java.lang.Object getBody()
//This method helps User to retrieve message body as specific type ( InputStream , String , byte[] ) - e.g. message.getBody(java.io.InputStream)
public java.lang.Object getBody(java.lang.String fullyQualifiedClassName)
def stockprice(prices)
puts "From the stocks:\n"
prices.each { |x| puts x}
to_buy = prices.min
prices.delete(to_buy)
to_sell = prices.max
puts "Buy for : #{to_buy}$\n"
puts "Sell for: #{to_sell}$\n"
puts "For a profit of #{to_sell - to_buy}$"
def firstTwoLetters(str)
return str[0,2]
end