Slackbot
12/12/2023, 8:14 PMTom
12/13/2023, 11:28 AM{
"matchesJsonPath": {
"expression": "$.messages[?(@.role == 'user')].content",
"contains": "Narrate the fight between a super hero and a super villain"
}
}
Eric Deandrea
12/13/2023, 1:54 PMEric Deandrea
12/13/2023, 1:54 PMEric Deandrea
12/13/2023, 2:14 PMmatches
instead of contains
, how do I escape a .
character?
For example, in something like this:
{
"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:
"[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:
$.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"