Skip to content

How do I validate whether the input provided is a valid JSON

This example demonstrates validating whether the JSON object is valid or not. 

In the solution shown below, the JSON object is validated using "jsonAssertValidity" command. The command returns "true" if the JSON is valid, else it returns "false".

Note: The notation to reuse the value of the variable in Worksoft SaaS is ${<Variable Name>}.

Solution:

# Command Target Value
Validate the JSON object and store the result in a variable
1 jsonAssertValidity {"zipcodeDetails":[{"zipcode":90001,"state": "California"},{"zipcode":10001,"state": "New York"}]}
JsonValidity

Tips, Tricks, Gotchas & Best Practices:  

  • As a best practice, it is always advisable to define the variable names without any spaces and if you want to differentiate the words, use underscores.


Feedback and Knowledge Base