I think it’s easier if request body can be commented.
{
“product”: “{{displayName}}”,
// “price” : “15.5”
}
Sorry in advance, I am not sure what to tag to.
I think it’s easier if request body can be commented.
{
“product”: “{{displayName}}”,
// “price” : “15.5”
}
Sorry in advance, I am not sure what to tag to.
JSON, the format used, does not allow comments.
Thank you for your answer, I also expect this answer.
I think we are using Postman, it is a tool.
The commenting out should be helped by the tool also. The testing should be easier if it can be commented out. If It is still insisted json can’t be commented out. It should be found a better ways.
As you can see we can embed a variable into the json body. The reason is Postman is a tool.
For example, before I post a request body in JS IDE, I also can comment out those json in the IDE also.
Why can’t Postman comment it out?
Which IDE supports that?
I mentioned about JS IDE, it is my mistake.
I confused between an JS object and json object. I think probably this suggestion will not work.
Thank you for your reply.
I think I found some solution of solving my problem:
=========================
Body Tab:
{{object}}
=========================
Pre-request Script Tab:
object = {
// product: “{{displayName}}”,
price : “15.5”
}
pm.environment.set(“object”, JSON.stringify(object));
========================
This is actually not a bad idea. I am glad you have found a solution and thank you for sharing👍
It would be much easier and appreciated if we could use javascript style commenting. It’s easy and everyone knows the meaning of //
I know that this is not that much good answer but for comment in JSON of postman I am adding new key which should not in use server side, which can help us to add some comment
Original json:
{
“name”: “My Name”,
“age”: 99
}
for comment:
{
“name”: “My Name”,
“age”: 99,
“_COMMENT$”: “This is my comment, but make sure that use some keyname which should not in use server side…”
}
There are a lot of json processors able to handle comments (think to DotNet Core settings files for example). Postman could simply and automatically do what’s suggested here: How to place comments in Postman - Stack Overflow
Bear in mind that the current Postman behavior can cause very weird errors/responses from the servers, today we spent 2 hours debugging the server side code before realizing the problem was a comment in the request body.
I LOVE the suggestion from @dpchudasama2(Profile - dpchudasama2 - Postman) - assuming POSTMAN doesn’t figure out this a simple request and do something proper about it. You can use it to comment/document fields. example:
“COMMENT_name” : “This field can accept only alphabetic characters”
I’ve got a prfect soluation just add this following code in the main collection > pre-request script to strip all comments from json raw
if(pm.request.body && pm.request.body.raw) pm.request.body.raw = pm.request.body.raw.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,'');
very nice solution @elkadrey
For me, the usecase is more like this, but your solution works perfectly