You need to sign in to do that
Don't have an account?
toufik_at
JSON Schema validation in APEX
Hi,
I wonder if there is in APEX a way to validate a JSON string against a defined json schema ?
Somthing like :
Link to the schema :
https://realtime-listings.webservices.zpg.co.uk/docs/v1.0/schemas/listing/update.json
I wonder if there is in APEX a way to validate a JSON string against a defined json schema ?
Somthing like :
If(isValid(jsonString, jsonSchema)) { doCallout(); }Basically, we are unable to make callouts to a third party system because they want us to validate our JSON payload with a schema before sending as part of their quality requirements.
Link to the schema :
https://realtime-listings.webservices.zpg.co.uk/docs/v1.0/schemas/listing/update.json
public boolean isValid(String JsoneString){
try{
jsonSchema jsonObj=new jsonSchema();
jsonObj=(jsonSchema)JSON.deserialize(JsoneString,jsonSchema);
return true;
}catch(Exception e){
return false;
}
}
public class jsonSchema{
String Name;
String Age;
}