SiKing
8 years agoCommunity Expert
context.expand produces different results between JSON and XML
I have some JSON response from a service, like:
{ "foo": "bar" }
I try to read this from a Groovy step, like:
log.info context.expand('${REST Request#Response#$..foo}') log.info context.expand('${REST Request#ResponseAsXml#//*:foo}')
In my log is get:
INFO: [bar] INFO: bar
Why the extra square brackets in the first case?
Either JSONpath expression $.foo (single dot) or $..foo[0] (the first occurrence in an array) would return a string.