废话少说,直接贴刚新鲜完成的源码;文章来源:https://www.toymoban.com/news/detail-803503.html
框架是Java+springboot+mybatisplus+testng+jenkins+git文章来源地址https://www.toymoban.com/news/detail-803503.html
@SpringBootTest public class MoreListTest extends AbstractTestNGSpringContextTests { @Autowired private RestTemplate restTemplate; @Autowired private UrlConfig urlConfig; @Test public void more() { String jsonString = "{\"a2w9_notice_title\":\"\",\"a2w9_release_start_time\":\"\",\"a2w9_release_end_time\":\"\",\"current\":1,\"pageSize\":7,\"a2w9_notice_type\":2}"; Map<String, Object> requestMap = new HashMap<>(); try { // 使用Jackson库解析JSON字符串为Map ObjectMapper objectMapper = new ObjectMapper(); Map<String, Object> jsonMap = objectMapper.readValue(jsonString, new TypeReference<Map<String, Object>>() { }); // 将解析得到的Map添加到requestMap中 requestMap.putAll(jsonMap); } catch (Exception e) { e.printStackTrace(); // 处理异常 }
到了这里,关于基于Java的接口自动化传参是json格式,如何转义的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!