Verify response failing when json element name is date like 01-01-2021

My json response is based on elements with date values like “01-01-2021”.
Every attempt to verify the response results in a crash…
WS.verifyElementPropertyValue(response, ‘AAPL.05-03-2021.adj_close’, ‘’)

Please let us know what you are using Katalon Studio for?

  1. I’m building a Proof of Concept

How would your work be affected if this issue has not been resolved?

  1. I cannot continue my job and have to work on something else while awaiting your response

Operating System

Windows 10

Katalon Studio Version

8.0.5 208

Katalon Studio logs

!ENTRY org.eclipse.e4.ui.workbench 4 0 2021-07-01 18:45:44.628
!MESSAGE
!STACK 0
java.lang.NullPointerException
at com.kms.katalon.custom.improvement.parser.ProjectCustomKeywordsParser.parseIFile(ProjectCustomKeywordsParser.java:136)
at com.kms.katalon.custom.improvement.parser.ProjectCustomKeywordsParser.parseKeywordFileAndWriteCache(ProjectCustomKeywordsParser.java:118)
at com.kms.katalon.custom.improvement.parser.ProjectCustomKeywordsParser.internallyParseKeywordFile(ProjectCustomKeywordsParser.java:99)
at com.kms.katalon.custom.improvement.parser.ProjectCustomKeywordsParser.parseKeywordFile(ProjectCustomKeywordsParser.java:61)
at com.kms.katalon.custom.improvement.parser.ImprovedCustomKeywordParser.parseCustomKeywordFile(ImprovedCustomKeywordParser.java:80)
at com.kms.katalon.controller.ImprovedKeywordControllerDelegate.parseCustomKeywordFile(ImprovedKeywordControllerDelegate.java:77)
at com.kms.katalon.controller.KeywordController.parseCustomKeywordFile(KeywordController.java:219)
at com.kms.katalon.composer.keyword.handlers.EditorSavedHandler.lambda$0(EditorSavedHandler.java:62)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

!ENTRY org.eclipse.jdt.groovy.core 4 0 2021-07-01 18:46:15.862
!MESSAGE Groovy-Eclipse Type Inferencing: Error visiting method main in class kat-4306651365501772774
!STACK 0
java.lang.NullPointerException
at org.eclipse.jdt.groovy.search.SimpleTypeLookup.findType(SimpleTypeLookup.java:349)
at org.eclipse.jdt.groovy.search.SimpleTypeLookup.lookupType(SimpleTypeLookup.java:98)
at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.lookupExpressionType(TypeInferencingVisitorWithRequestor.java:2702)
at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleSimpleExpression(TypeInferencingVisitorWithRequestor.java:2004)
at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleSimpleExpression(TypeInferencingVisitorWithRequestor.java:2009)
at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitStaticMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1671)
at org.codehaus.groovy.ast.expr.StaticMethodCallExpression.visit(StaticMethodCallExpression.java:43)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:120)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:269)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:148)
at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstructorOrMethod(TypeInferencingVisitorWithRequestor.java:1112)
at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodInternal(TypeInferencingVisitorWithRequestor.java:659)
at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:467)
at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:376)
at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitCompilationUnit(TypeInferencingVisitorWithRequestor.java:256)
at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.internalFindOccurences(GroovyOccurrencesFinder.java:138)
at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.getOccurrences(GroovyOccurrencesFinder.java:86)
at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.findOccurrences(GroovyOccurrencesFinder.java:194)
at org.codehaus.groovy.eclipse.editor.GroovyEditor.updateOccurrenceAnnotations(GroovyEditor.java:1314)
at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$6.selectionChanged(JavaEditor.java:3383)
at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:184)
at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:160)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

!ENTRY org.eclipse.e4.ui.workbench 4 0 2021-07-01 18:46:24.566
!MESSAGE
!STACK 0
java.lang.NullPointerException
at com.kms.katalon.custom.improvement.parser.ProjectCustomKeywordsParser.parseIFile(ProjectCustomKeywordsParser.java:136)
at com.kms.katalon.custom.improvement.parser.ProjectCustomKeywordsParser.parseKeywordFileAndWriteCache(ProjectCustomKeywordsParser.java:118)
at com.kms.katalon.custom.improvement.parser.ProjectCustomKeywordsParser.internallyParseKeywordFile(ProjectCustomKeywordsParser.java:99)
at com.kms.katalon.custom.improvement.parser.ProjectCustomKeywordsParser.parseKeywordFile(ProjectCustomKeywordsParser.java:61)
at com.kms.katalon.custom.improvement.parser.ImprovedCustomKeywordParser.parseCustomKeywordFile(ImprovedCustomKeywordParser.java:80)
at com.kms.katalon.controller.ImprovedKeywordControllerDelegate.parseCustomKeywordFile(ImprovedKeywordControllerDelegate.java:77)
at com.kms.katalon.controller.KeywordController.parseCustomKeywordFile(KeywordController.java:219)
at com.kms.katalon.composer.keyword.handlers.EditorSavedHandler.lambda$0(EditorSavedHandler.java:62)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Screenshots / Videos

Please share more information. Have a look at this guidance:

My restAPI call response looks like this:
{
“AAPL”: {
“05-03-2021”: {
“adj_open”: 132.04,
“adj_high”: 134.07,
“adj_low”: 131.83,
“adj_close”: 132.54,
“adj_volume”: 75135100.0,
“dividend”: 132.316
}
}
}

I would like to verify the data, and am using code like this:
WS.verifyElementPropertyValue(response, ‘AAPL.05-03-2021.adj_open’, ‘132.04’)

The verification is having issues with the date part of the element name and crashes.
Here is the verification log

2021-07-02 11:40:42.617 INFO c.k.k.core.main.WSVerificationExecutor - --------------------
2021-07-02 11:40:42.620 INFO c.k.k.core.main.WSVerificationExecutor - START Verification
2021-07-02 11:40:43.388 ERROR c.k.k.core.keyword.internal.KeywordMain - ? Unable to verify element property value (Root cause: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unexpected token: 05 @ line 1, column 98.
xt(jsonText);return root.AAPL.05-03-2021
^

1 error

at com.kms.katalon.core.webservice.helper.WebServiceCommonHelper.parseAndGetPropertyValueForJson(WebServiceCommonHelper.java:213)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword$_verifyElementPropertyValue_closure1.doCall(VerifyElementPropertyValueKeyword.groovy:52)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword$_verifyElementPropertyValue_closure1.call(VerifyElementPropertyValueKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword.verifyElementPropertyValue(VerifyElementPropertyValueKeyword.groovy:48)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword.execute(VerifyElementPropertyValueKeyword.groovy:43)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.verifyElementPropertyValue(WSBuiltInKeywords.groovy:189)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords$verifyElementPropertyValue$0.call(Unknown Source)
at WSVerification1625244042669.run(WSVerification1625244042669:21)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.WSVerificationExecutor.runScript(WSVerificationExecutor.java:178)
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:172)
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:155)
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:147)
at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:129)
at com.kms.katalon.core.main.TestCaseMain.runWSVerificationScript(TestCaseMain.java:155)
at com.kms.katalon.core.main.TestCaseMain$runWSVerificationScript$0.call(Unknown Source)
at TempTestCase1625244040098.run(TempTestCase1625244040098.groovy:25)

)
2021-07-02 11:40:43.398 ERROR c.k.k.core.main.WSVerificationExecutor - ? Verification FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to verify element property value (Root cause: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unexpected token: 05 @ line 1, column 98.
xt(jsonText);return root.AAPL.05-03-2021
^

1 error

at com.kms.katalon.core.webservice.helper.WebServiceCommonHelper.parseAndGetPropertyValueForJson(WebServiceCommonHelper.java:213)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword$_verifyElementPropertyValue_closure1.doCall(VerifyElementPropertyValueKeyword.groovy:52)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword$_verifyElementPropertyValue_closure1.call(VerifyElementPropertyValueKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword.verifyElementPropertyValue(VerifyElementPropertyValueKeyword.groovy:48)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword.execute(VerifyElementPropertyValueKeyword.groovy:43)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.verifyElementPropertyValue(WSBuiltInKeywords.groovy:189)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords$verifyElementPropertyValue$0.call(Unknown Source)
at WSVerification1625244042669.run(WSVerification1625244042669:21)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.WSVerificationExecutor.runScript(WSVerificationExecutor.java:178)
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:172)
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:155)
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:147)
at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:129)
at com.kms.katalon.core.main.TestCaseMain.runWSVerificationScript(TestCaseMain.java:155)
at com.kms.katalon.core.main.TestCaseMain$runWSVerificationScript$0.call(Unknown Source)
at TempTestCase1625244040098.run(TempTestCase1625244040098.groovy:25)

)
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:50)
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:70)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword.verifyElementPropertyValue(VerifyElementPropertyValueKeyword.groovy:48)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword.execute(VerifyElementPropertyValueKeyword.groovy:43)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.verifyElementPropertyValue(WSBuiltInKeywords.groovy:189)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords$verifyElementPropertyValue$0.call(Unknown Source)
at WSVerification1625244042669.run(WSVerification1625244042669:21)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.WSVerificationExecutor.runScript(WSVerificationExecutor.java:178)
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:172)
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:155)
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:147)
at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:129)
at com.kms.katalon.core.main.TestCaseMain.runWSVerificationScript(TestCaseMain.java:155)
at com.kms.katalon.core.main.TestCaseMain$runWSVerificationScript$0.call(Unknown Source)
at TempTestCase1625244040098.run(TempTestCase1625244040098.groovy:25)
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unexpected token: 05 @ line 1, column 98.
xt(jsonText);return root.AAPL.05-03-2021
^

1 error

at com.kms.katalon.core.webservice.helper.WebServiceCommonHelper.parseAndGetPropertyValueForJson(WebServiceCommonHelper.java:213)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword$_verifyElementPropertyValue_closure1.doCall(VerifyElementPropertyValueKeyword.groovy:52)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementPropertyValueKeyword$_verifyElementPropertyValue_closure1.call(VerifyElementPropertyValueKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
... 16 more

2021-07-02 11:40:43.406 INFO c.k.k.core.main.WSVerificationExecutor - END Verification

You have this:

WS.verifyElementPropertyValue(response, 'AAPL.05-03-2021.adj_open', '132.04')

You should change this to:

WS.verifyElementPropertyValue(response, 'AAPL["05-03-2021"].adj_open', '132.04')

Why?
Please study the following example of digesting a text in json format:

import groovy.json.JsonSlurper

String responseText = """{
	"AAPL": {
		"05-03-2021": {
			"adj_open": 132.04,
			"adj_high": 134.07,
			"adj_low": 131.83,
			"adj_close": 132.54,
			"adj_volume": 75135100.0,
			"dividend": 132.316
		}
	}
}
"""

JsonSlurper slurper = new JsonSlurper()

def json = slurper.parse(new StringReader(responseText))

println json.AAPL
//println json.AAPL.05-03-2021    // Groovy detects a syntax error
println json.AAPL["05-03-2021"]
println json.AAPL["05-03-2021"].adj_open

In the above code, json.AAPL is an instance of Map. See
https://groovy-lang.org/syntax.html#_maps

How to get properties of a Map object? You can write

json.AAPL["05-03-2021"]

But you can not write

json.AAPL.05-03-2021

because Groovy interprets this as

json.AAPL.05  -  03  - 2021

where you want to get the value of json.AAPL.05 minus 03 minus 2021. But 05 is not a normal identifier in Groovy; 05 is a digit value. Therefore Groovy throws an error:

Script1.groovy: 1: unexpected token: 05 @ line 1, column 98.
                                     ^^

That fixed it. Thank you. 100%
If there is an “Answered” flag or similar, please note it.

Thank you again!