Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to call the function format of postman

Shulou Source: shulou.com Published: 2022-05-31 10:38:12 11月09日 Update

In this article Xiaobian for you to introduce in detail "how to call postman function format", the content is detailed, the steps are clear, the details are handled properly, I hope this "how to call postman function formatting" article can help you solve your doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.

Method 1: upgrade version formatting

1. Upgrade to version version 6.7.4

2. Click Beautify to format the JSON in Body.

Method 2: call the function format of postman

Package com.java.example.demo.postman;import com.alibaba.fastjson.JSONObject;import org.springframework.http.HttpHeaders;import org.springframework.http.HttpStatus;import org.springframework.http.ResponseEntity;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.bind.annotation.RestController;import java.util.HashMap;import java.util.Map / * * use of constants and functions in postman * * scenario: * secondFunction method depends on the result executed by the firstFunction method * use a postman request to resolve * / @ RestControllerpublic class Constant {@ GetMapping ("/ first") @ ResponseBody public ResponseEntity firstFunction (@ RequestParam String param) {return res (param + "- init") } @ GetMapping ("/ second") @ ResponseBody public ResponseEntity secondFunction (@ RequestParam String param) {return res ("processed random number:" + param);} private static ResponseEntity res (Object object) {Map map = new HashMap (); map.put ("res", object); return jsonResult (JSONObject.toJSONString (map));} public static ResponseEntity jsonResult (String result) {HttpHeaders resHeaders = new HttpHeaders () ResHeaders.set ("Content-Type", "application/json;charset=UTF-8"); return new ResponseEntity (result, resHeaders, HttpStatus.OK);}} read here, this article "how to call the function format of postman" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it to understand it. If you want to know more about related articles, please follow the industry information channel.

Tags: Format function method article content version upgrade proper scenario constant ideas new knowledge more steps knowledge knowledge points articles details results industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Information Shulou Technology MySQL macOS