postmanerator icon indicating copy to clipboard operation
postmanerator copied to clipboard

Nested JSON response

Open guymaor86 opened this issue 8 years ago • 4 comments

Hi, I'm using the postmanerator for documenting my API calls, but I have a problem with one use case. One of my responses that I saved are as follows:

 {
  "id": "1234",
  "user": {
    "firstName": "FName",
    "lastName": "LName",
    "email": "[email protected]"
  }
}

But when I run the posmanerator I don't get any result in the response and I think it's because of the nested json. If I change the response to this(wrapping the inner json with an array) then everything works:

 {
  "id": "1234",
  "user": [{
    "firstName": "FName",
    "lastName": "LName",
    "email": "[email protected]"
  }]
}

Do you have any idea what's happening here? maybe I did something wrong? I used the default theme

guymaor86 avatar Dec 04 '16 12:12 guymaor86

Hello, I'm afraid I did not succeed to reproduce the error.

I used the following test collection file: collection-test.json.txt.

Here is the command I used: postmanerator -collection collection.json -output index.html.

And here is the index.html that was generated: index.html.txt

Maybe there is something specific with your collection, is it possible for you to share a version of it that I can use to reproduce the behavior?

aubm avatar Dec 04 '16 21:12 aubm

Hi,

Thanks for the quick response. Your piece of code works for me too, so I was confused, but I figured out what the problem is. I looked inside your json file and mine, and in yours the response looks like this:

"text": "{\n \"id\": \"1234\",\n \"user\": {\n \"firstName\": \"FName\",\n \"lastName\": \"LName\",\n \"email\": \"[email protected]\"\n }\n}",

and in mine:

"text": "{ \"id\": \"1234\",\"user\": { \"firstName\": \"FName\", \"lastName\": \"LName\", \"email\": \"[email protected]\" }}",

For some reason the my postman doesn't generate the new lines inside the json file. When I go manually and add them then everything works fine. Do you have any idea why my postman won't generate them? And why does your code care if there are new lines or not in the response? Thanks in advance

guymaor86 avatar Dec 05 '16 10:12 guymaor86

Sorry, this is a long week... I'll check that in the week-end :)

aubm avatar Dec 09 '16 07:12 aubm

Hello, so I tried to replace the text attribute of my test collection with the one you have (without the new lines) and it still works fine for me :/

Could you please tell me a bit more about:

  • what operating system you have
  • what version of Postman you use
  • are you sure you use the latest build of Postmanerator?

Also maybe you did notice any other differences between your collection file and the one I used for my test?

Sorry that it doesn't work for you now!

aubm avatar Dec 10 '16 08:12 aubm