This message was deleted.
# help
s
This message was deleted.
t
Might be easier to use a sub-matcher here e.g.
Copy code
{
  "matchesJsonPath": {
    "expression": "$.messages[?(@.role == 'user')].content",
    "contains": "Narrate the fight between a super hero and a super villain"
  }
}
e
That works!
thank you @Tom!
One follow-up @Tom If I change to use
matches
instead of
contains
, how do I escape a
.
character? For example, in something like this:
Copy code
{
  "matchesJsonPath": {
    "expression": "$.messages[?(@.role == 'user')].content",
    "matches": "Narrate the fight between a super hero and a super villain."
  }
}
How would I escape the period at the end? If I just use
\
I get errors on startup:
Copy code
"[truncated 3202 chars]; line: 34, column: 83]
        at com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource.loadMappingsInto(JsonFileMappingsSource.java:123)
        at com.github.tomakehurst.wiremock.core.WireMockApp.loadMappingsUsing(WireMockApp.java:265)
        at com.github.tomakehurst.wiremock.core.WireMockApp.loadDefaultMappings(WireMockApp.java:259)
        at com.github.tomakehurst.wiremock.core.WireMockApp.<init>(WireMockApp.java:124)
        at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:71)
Yet If I use
\\
to escape it, my matcher no longer works because one of the
\
characters is still there in the matcher:
Copy code
$.messages[?(@.role == 'user')].content [matches] Narrate  | Narrate the fight between a super hero and a super  <<<<< Body does not match
the fight between a super hero and a super                 | villain.
villain\.                                                  | During the narration, don't repeat "super hero"