Pm.response.json() - Response as Object

Hi Experts,

I want to bring dynamicity when parsing through the API response received. To achieve that, trying to pass the Key to the object and get the value, which is achievable with javascript.

My response body:


Theoretically, I should be able to get “John” with

var jsonData = pm.response.json();

var x = jsonData["name.title"];

however, this is not happening as expected; can someone give me an expertise suggestion.

Maybe I am not parsing the response body; how can I get response body alone from pm.response

Hey @srk.groups,

Welcome to the community! :rocket:

It looks like you using both bracket and dot notion in the same line.

You should be able to use either of these to get the value from the object.

var x = jsonData["name"]["title"];

var x =;   

However, if your response was something like this:


Then your syntax would be correct as that would be the correct way to access that keys value.

Hope that helps. :slight_smile:

Thank you for the comments @dannydainton

was trying to do something like this


Is there some sort of possibility; as “name.title” will be passed as a header from csv.

That should work fine with a CSV data file in the runner.

pm.test("Basic Test", function () {

If the column header is name.title is will pick up that reference and use the value from that in the assertion.


yes that will work; the ultimate goal is to iterate multiple columns from csv - i am still in research mode.

For that part it the solution will not work:-pm.expect(“name.title”)

csv holds:

in this i am trying to bring in the dynamicity; :slight_smile:

2 things here i want o achieve,

  1. Iterate through column of csv,
  2. Set object property dynamically

1st iteration of the loop
pm.expect(jsonData[“ name.title ”]).to.eql(pm.iterationData.get(“ name.title ”))

2nd iteration of the loop
pm.expect(jsonData[“ name.firstname ”]).to.eql(pm.iterationData.get(“ name.firstname ”))

3rd iteration of the loop
pm.expect(jsonData[“ name.lastname ”]).to.eql(pm.iterationData.get(“ name.lastname ”))

if your can provide me some direction, that would be a help

Can you add some images or what you have so far, just so I can understand how far you’ve got and what’s not working?

If I understand correctly, is this what you’re trying to do?

I’ve just set your response data as a variable inside the Tests script but it would work the same if you use pm.response.json(). Each request in the collection has a single test, to compare the response data with the data in the CSV file.


If this isn’t what you were trying to do, could you share the structure of your collection, please?


Commented part is a prototyping of what i want to achieve; sample csv also attached the “DrillDownToResponse” is a boolean operator which pivots whether i need to drill down into response details or not.

@dannydainton and Team - can you give me some direction on this.