Hi,
I am trying to build a cloud rule of transform type, which accepts the JSON and JSONPATH as arguments. Returns the result from JsonPath expression.
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule name="Parse JSON value" type="Transform">
<Description>Generic Rule to return string value. To be used in transform.
Input parameters.
Input : JSON_PAYLOAD = The Payload from which the value needs to extracted.
JSON_PATH = That path from which value needs to be extracted.
</Description>
<Source><![CDATA[
import com.jayway.jsonpath.JsonPath;
import net.minidev.json.*;
String RULE_NAME = "[Rule - Transform - Parse JSON value]";
String JSON_PAYLOAD= INPUT_JSON_PAYLOAD;
public String getStringFromJson (String input) {
try {
log.error(RULE_NAME + " Incoming Value for : JSON [" + JSON_PAYLOAD + "]");
log.error(RULE_NAME + " Incoming Value for : JSON_PATH [" + input + "]");
Object result = JsonPath.read(JSON_PAYLOAD, input);
log.error(RULE_NAME + " Returning Value : [" + result + "]");
return result.toString();
} catch (Exception e) {
log.error(" Exception Occured while attribute from JSON_PATH. " + input + " : " + e);
return null;
}
return null;
}
return getStringFromJson(input);
]]></Source>
</Rule>
The rule when called from transform throws an exception on JsonPath.read. The statement is valid and runs locally. Similar statements are sucessfully executed within context of connector rules. However it fails within cloud rule’s context.
Has anyone encountered similar situation.? Does anyone know which JsonParser libraries are available in cloud. ?