# Get the value from a property with a special character in the name

**URL:** <https://forum.katalon.com/t/get-the-value-from-a-property-with-a-special-character-in-the-name/95224>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [September 6, 2023, 5:37pm UTC](https://forum.katalon.com/t/get-the-value-from-a-property-with-a-special-character-in-the-name/95224 "2023-09-06T17:37:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![manuel.guevara](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/manuel.guevara/32/20464_2.png) [@manuel.guevara](https://forum.katalon.com/u/manuel.guevara)\
**Post date:** [September 6, 2023, 5:37pm UTC](https://forum.katalon.com/t/get-the-value-from-a-property-with-a-special-character-in-the-name/95224/1 "2023-09-06T17:37:48Z")

</div>

Hello guys.

I’m not able to get a value because the property name has special characters

example:  
“Result”:{“@type”:“Result”}

If I do

WSBuiltInKeywords.verifyElementPropertyValue(response, ‘Result.@type’, ‘Something’)

or

WS.getElementPropertyValue(response,‘Result.@type’)

ERROR c.k.k.core.keyword.internal.KeywordMain - ? Unable to verify element property value (Root cause: groovy.lang.MissingFieldException: No such field: type for class: groovy.json.internal.LazyMap

ERROR c.k.k.core.main.WSVerificationExecutor - ? Verification FAILED.  
Reason:  
com.kms.katalon.core.exception.StepFailedException: Unable to verify element property value (Root cause: groovy.lang.MissingFieldException: No such field: type for class: groovy.json.internal.LazyMap

Open to ideas hehe, thanks!

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [September 6, 2023, 8:17pm UTC](https://forum.katalon.com/t/get-the-value-from-a-property-with-a-special-character-in-the-name/95224/2 "2023-09-06T20:17:02Z")

</div>

Please use “Code Formatting syntax” for code, log, file content for better readability

 ![code formatting](https://europe1.discourse-cdn.com/katalon/original/3X/5/e/5e1176e92ca803beadcb58f98c2d0df8b9ae623d.png)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [September 6, 2023, 9:02pm UTC](https://forum.katalon.com/t/get-the-value-from-a-property-with-a-special-character-in-the-name/95224/3 "2023-09-06T21:02:14Z")

</div>

> [@manuel.guevara](#):
>
> example:  
> “Result”:{“@type”:“Result”}

This is not a valid JSON. It would never be properly processed by any JSON Parser.

I guess you wanted

```auto
{"Result":{"@type":"Result"}}

```

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [September 6, 2023, 9:06pm UTC](https://forum.katalon.com/t/get-the-value-from-a-property-with-a-special-character-in-the-name/95224/4 "2023-09-06T21:06:08Z")

</div>

You can find the source code of `WS.verifyElementPropertyValue` keyword at

> <https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/webservice/keyword/builtin/VerifyElementPropertyValueKeyword.groovy>

You should read the source to investigate whatever problem about the keyword.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [September 6, 2023, 9:07pm UTC](https://forum.katalon.com/t/get-the-value-from-a-property-with-a-special-character-in-the-name/95224/5 "2023-09-06T21:07:59Z")

</div>

I could reproduce the problem with the following code:

```auto
import com.kms.katalon.core.webservice.helper.WebServiceCommonHelper as WSCH

String content = '''{"Result":{"@type":"Value"}}'''

Object obj = WSCH.parseAndGetPropertyValueForJson('Result.@type', content)
println obj

```

Console output:

```auto
2023-09-07 05:59:47.261 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2023-09-07 05:59:47.264 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/TC1
2023-09-07 05:59:47.712 DEBUG testcase.TC1 - 1: content = "{"Result":{"@type":"Value"}}"
2023-09-07 05:59:47.715 DEBUG testcase.TC1 - 2: obj = parseAndGetPropertyValueForJson("Result.@type", content)
2023-09-07 05:59:47.804 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/TC1 FAILED.
Reason:
groovy.lang.MissingFieldException: No such field: type for class: groovy.json.internal.LazyMap
	at Script1.run(Script1.groovy:1)
	at com.kms.katalon.core.webservice.helper.WebServiceCommonHelper.parseAndGetPropertyValueForJson(WebServiceCommonHelper.java:243)
	at com.kms.katalon.core.webservice.helper.WebServiceCommonHelper$parseAndGetPropertyValueForJson.call(Unknown Source)
	at TC1.run(TC1:5)
	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.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:144)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:135)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1694033984090.run(TempTestCase1694033984090.groovy:25)

2023-09-07 05:59:47.832 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/TC1 FAILED.
Reason:
groovy.lang.MissingFieldException: No such field: type for class: groovy.json.internal.LazyMap
	at Script1.run(Script1.groovy:1)
	at com.kms.katalon.core.webservice.helper.WebServiceCommonHelper.parseAndGetPropertyValueForJson(WebServiceCommonHelper.java:243)
	at com.kms.katalon.core.webservice.helper.WebServiceCommonHelper$parseAndGetPropertyValueForJson.call(Unknown Source)
	at TC1.run(TC1:5)
	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.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:144)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:135)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1694033984090.run(TempTestCase1694033984090.groovy:25)

2023-09-07 05:59:47.866 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/TC1

``
```

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [September 6, 2023, 9:10pm UTC](https://forum.katalon.com/t/get-the-value-from-a-property-with-a-special-character-in-the-name/95224/6 "2023-09-06T21:10:51Z")

</div>

The following code worked:

```auto
import com.kms.katalon.core.webservice.helper.WebServiceCommonHelper as WSCH

String content = '''{"Result":{"@type":"Value"}}'''

Object obj = WSCH.parseAndGetPropertyValueForJson('Result."@type"', content)
println obj

```

Output:

```auto
2023-09-07 06:09:38.736 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2023-09-07 06:09:38.740 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/TC2
2023-09-07 06:09:39.200 DEBUG testcase.TC2 - 1: content = "{"Result":{"@type":"Value"}}"
2023-09-07 06:09:39.202 DEBUG testcase.TC2 - 2: obj = parseAndGetPropertyValueForJson("Result."@type"", content)
2023-09-07 06:09:39.312 DEBUG testcase.TC2 - 3: println(obj)
Value
2023-09-07 06:09:39.343 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/TC2

```

See the doc of [`GPath`](https://docs.groovy-lang.org/latest/html/documentation/core-semantics.html#gpath_expressions) for detail.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [September 10, 2023, 4:23am UTC](https://forum.katalon.com/t/get-the-value-from-a-property-with-a-special-character-in-the-name/95224/8 "2023-09-10T04:23:01Z")

</div>

One more exercise:

```auto
import com.kms.katalon.core.webservice.helper.WebServiceCommonHelper as WSCH

String content = '''{"Result":{"@type":"Value"}}'''

Object obj = WSCH.parseAndGetPropertyValueForJson('Result["@type"]', content)
println "obj=" + obj

```

This worked fine:

```auto
2023-09-10 13:17:08.508 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2023-09-10 13:17:08.511 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/testGPath
Test Cases/testGPath
[:]
obj=Value
Test Cases/testGPath
PASSED
2023-09-10 13:17:09.154 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/testGPath

```

This proves that the expression `'Result["@type"]'` is evaluated valid.

The expression `'Result["@type"]'` looks familiar to me. It is just the same as a code in JavaScript that gets access to a property of an object.

On the other hand, the expression `'Result."@type"'` looks puzzling to me. I have never seen this syntax in any other places.
