Problem accessing json data path with colon in name

405 views
Skip to first unread message

tigernutt

unread,
Mar 29, 2016, 12:12:21 AM3/29/16
to REST assured
Given the following JSON:

{
  "id": "Docs",
  "indexFile": [
    "index.html",
    "index.htm"
  ],
  "urn:acme:schemas:messages:2.0": {
    "requiredActions": [
      {
        "type": "componentRestart",
        "synopsis": "You must restart this component for the changes made."
      }
    ]
  }
}

If I try and verify the content for the "urn:acme..." path like so:

assertThat().body("urn:acme:schemas:messages:2.0.requiredActions.any { it.containsKey('type') }", equalTo("componentRestart")).


It fails with the following error, apparently due to issues with groovy and colons:


Script1.groovy: 1: expecting EOF, found ':' @ line 1, column 30.

   restAssuredJsonRootObject.urn:acme:schemas:messages:2.0.requiredActions.any { it.containsKey('type') }


Any assistance on how to verify the contents of the requiredActions array would be appreciated!


Doug

Johan Haleby

unread,
Mar 29, 2016, 12:14:11 AM3/29/16
to rest-a...@googlegroups.com
Try escaping urn:acme:schemas:messages:2.0, i.e. 'urn:acme:schemas:messages:2.0'

Regards
/Johan

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tigernutt

unread,
Mar 29, 2016, 9:53:55 AM3/29/16
to REST assured
Thank you Johan, that corrected my problem.
Reply all
Reply to author
Forward
0 new messages