orbeon

Check text for valid JSON string


We paste a JSON string into one of our form controls which is then used by another application to generate data.

We need a way of validating this JSON string before the form is saved/submitted.

How can we achieve this?


Solution

  • In the Control Settings dialog for your text area, navigate to the Validations and Alerts tab and use the following formula to validate the value of the field (as shown in the screenshot below).

    exists(xxf:json-to-xml(.))
    

    Control Settings dialog