I have a JSON response that looks like
{
“a”: “2025-08-28T16:53:16”,
“b”: 1756425196,
“a-b”: 323223
}
How to I refer to a-b in Post Processor Assertion.
for a I use $.a
I have a JSON response that looks like
{
“a”: “2025-08-28T16:53:16”,
“b”: 1756425196,
“a-b”: 323223
}
How to I refer to a-b in Post Processor Assertion.
for a I use $.a
To refer to the “a-b” field in Post Processor Assertion, you can use the JSONPath expression: $.['a-b']
.
Hover over the right side of the response body field to see the assertion and variable extraction entry. Clicking the popup will auto-fill the JSONPath expression. If you don’t see the entry, please update to the latest version.
That worked. The only change made was to use double quotes because single quotes in Assertions caused an error.
It did not work. This works in a custom script. console.log(“expiration-date=” + pm.response.json()[“a-b”]);
but $.[‘a-b’] in Assertions shows this error. PostProcessor Script Error: Unexpected identifier ‘a’
You can use the assertion component for this, and I’ve confirmed it works. Please refer to the settings in the image.
I confirm Equals works. My assertion uses Exists. Does it work for you?
I can confirm the issue with Exists is reproducible. We’re checking it now and will update you as soon as we have more information.
Thanks for the update. Is there a workaound. Can “Does Not Equal” be used and if so. How do I say != null as a way to achieve the same result as Exists. Let me know.
You can use a Custom Script to verify if this field exists. Here’s a script example for you:
const responseJson = pm.response.json();
// Assert that the $.['a-b'] field exists
pm.test("Check if 'a-b' field exists", function () {
// Check if the field exists using hasOwnProperty method
pm.expect(responseJson).to.have.property('a-b');
// Alternatively, check if the field is not undefined
// pm.expect(responseJson['a-b']).to.not.be.undefined;
});