How to validate json using groovy script
Hii, i want to validate below json column and their value using groove script but it seems bot working for me.
Can anyone let me know
[
“Type” : health
“Date”: “2021-09-09”
{
Department {
“Name”: “abc”
“Id”: “123”
}
“Expensive”
{
“Type “ : “abc”
“Amount “: “123”}
Answers
-
Why not use the Diff tool or JSON Assertor tool? SOAtest has various built in tools so you can perform validations without having to script anything. For more detail, see my previous answer here: Json file validation
Otherwise, you can use an Extension Tool to execute a script. For Groovy, see Parsing and producing JSON.
0 -
@benken_parasoft aaBecause i have huge data in json file and every time sequence of json array(data)get changed..can you suggest me the option to validate
0 -
Because i have huge data in json file
Size isn't necessarily an issue.
and every time sequence of json array(data)get changed
See:
Compare 2 API's json responses coming in different Order
Diff JSON comparision by ignoring the order
Validating responses when order of individual elements changes
Comparing Json Responses0