Re: Validating JSON?

> JSON doesn't (yet) have anything like schemas, so if you want to validate it the easiest path is to convert it to XML and validate the XML.
>
this is not true, there is a proposed Internet draft "JSON Schema" (JSON Schema is to JSON as XSD is to XML): http://json-schema.org/
Examples page:http://json-schema.org/examples.html

But DataPower firmwares up to 5.0.0.x do not support that JSON Schema validation.

Re: Validating JSON?

Is there any way in DatapowerXI50 5.0.0.3 to send customized error messagein JSON format for invalid JSON requests?
The invalid JSON request messages are rejected in the transaction step 0 only before match action is executed and consumers recieves a soap fault instead of JSON fault.
I understand it would be ridiculous to send invalid JSON requests from the consumer app side in the first hand but I am being curious.

Re: Validating JSON?

The way we have done is, we added an ErrorRule, which capture the SOAPFault and then we make a JSONX with our own error code and custom description and before sending back, use store://jsonxtojson.xsl file.

Re: Validating JSON?

I have a same scenario to validate the incoming JSON request. I am trying the same thing but my json is schema is not validating the request. I might be wrong with the schema. Could you please provide any sample request and json schema to validate.

Re: Validating JSON?

Off topic: I am not sure it's a good idea to use enum for employee ID, unless you want to maintain all employee IDs in your schema. The same may hold true for number (depends on what number means). But I would definitively use it in location.

Re: Validating JSON?

I've used this site in the past: http://jsonschema.net/ ... You can provide a schema and have it generate a sample JSON document or visa versa. Beware of your firmware version and the schema produced as DataPower 6.0 supported on version of the schema and 7.0 added support for a later version of the schema, so you need to ensure your produced schema is supported by your appliance firmware.