简体   繁体   English

如何将嵌套的JSON数据导入Postman的收集运行器?

[英]How to import nested JSON data into Postman's collection runner?

I have the following 'nested JSON' data: 我有以下“嵌套JSON”数据:

[{  
   "method":"POST",
   "endpoint":"/users",
   "body":{  
      "username":"ZStGQoTVGvtBO",
      "role":"DEVICE_ADMINISTRATOR"
   },
   "res_code":400,
   "auth":[  
      "4565786",
      "bncfgnjfgnjgt"
   ]
}] 

How to import it into Postman collection runner? 如何将其导入Postman CollectionRunner? I am able to import simple JSON data but not nested JSON. 我可以导入简单的JSON数据,但不能导入嵌套的JSON。 And also there seems to be a problem in importing the "auth" element sometimes it's ignoring the "auth" element, sometimes it's just importing the second value of "auth" only. 而且在导入“ auth”元素时似乎也存在问题,有时它忽略了“ auth”元素,有时只是仅导入了“ auth”的第二个值。

You can do it manually in pre-request script: 您可以在请求前脚本中手动进行操作:

pm.variables.set("username", data.body.username);//<- acess to nested value, you can't use {{body.username}}

or if you want to input some part of your data to request body you can: 或者,如果您想输入部分数据以请求正文,则可以:

pm.variables.set("bodyPart", JSON.stringify(data.someobject))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Postman Collection Runner中使用包含JSON对象的模板变量 - Using a template variable that contains a JSON object with Postman Collection Runner 如何将嵌套的 JSON 数据导入 JavaScript - how to import nested JSON data into JavaScript 如何使用 Postman 检查嵌套 JSON 中的值 - How to Check a value in a nested JSON using Postman 如何将json文件中的数据导入mongodb图集集合 - How to import data from json file to mongodb atlas collection 如何使用Postman将数据插入Solr集合? - How to insert data to solr collection using Postman? 如何使用Postman解析嵌套JSON中的值 - How to Parse a value in a nested JSON using Postman 如何使用节点 js 在 Cloud Firestore 中导入集合和嵌套集合数据? - How to import collection and nested collection data in cloud firestore using node js? 如何从嵌套的JSON响应中获取数据并传递给邮递员中的下一个请求? - How to fetch data from nested JSON response and pass to next request in postman? 如何使用 postman 一起发送图像/文件和嵌套的 json 数据? - How can i send image/file and nested json data together using postman? 如何将 Postman 正文中带有嵌套数组字段的原始 JSON 转换为表单数据? - How to convert raw JSON with nested array field in Postman body into form-data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM