Hi Anirban,
For Gateway 9.4, the JavaScript assertion can be used to validate JSON structure. Prior to 9.4, I am thinking maybe the Evaluate JSON Path Expression assertion v2.
In the latter case, setup a simple expression, $, inside an at least one branch
At least one
-Evaluate JSON Path
-set result to invalid JSON
If there are 0 or more results, the Evaluate statement passes, otherwise , if something goes wrong, return the invalid JSON message.
For JavaScript
var json = context.getVariable ('request.mainpart');
try {
JSON.parse(json);
context.setVariable("result","valid JSON");
} catch (e) {
context.setVariable("result","invalid JSON");
}
Original Message:
Sent: 03-05-2020 05:05 AM
From: Anirban Chakraborty
Subject: Validate JASON input structure only
Want to validate JSON input structure only. Requirement is if the input is not in proper JSON format then have to throw custom error message. line"The input is not JSON format"
Input is like below:
{
"input" : {
"EmailId" : "abc",
"Flag" : "ee",
"RecordId" : "55"
}
}
N.B:Schema validation not required.