赞
踩
先读取到json文件字符串(见naocs),然后转成Java对象(主要在实体类)
Properties properties = System.getProperties();
properties.setProperty("serverAddr", System.getProperty(Constants.NACOS_CONFIG_ADDR_KEY));
properties.setProperty("username", System.getProperty(Constants.NACOS_CONFIG_USERNAME_KEY));
properties.setProperty("password", System.getProperty(Constants.NACOS_CONFIG_PASSWORD_KEY));
properties.setProperty("contextPath", System.getProperty(Constants.NACOS_CONFIG_CONTEXT_PATH_KEY));
properties.setProperty("namespace", System.getProperty(Constants.NACOS_CONFIG_NAMESPACE_KEY));
ConfigService configService = ConfigFactory.createConfigService(properties);
String ocppJsonStr = configService.getFileContent(dataId, group);
return JSONObject.parseObject(ocppJsonStr, PostmanVO.class);
@Data @AllArgsConstructor @NoArgsConstructor @Builder @JsonInclude(JsonInclude.Include.NON_NULL) public class PostmanVO { private InfoVO info; private List<ItemVO> item; } @Data @AllArgsConstructor @NoArgsConstructor @Builder @JsonInclude(JsonInclude.Include.NON_NULL) public class InfoVO { private String _postman_id; private String name; private String schema; private String _exporter_id; private String _collection_link; } @Data @AllArgsConstructor @NoArgsConstructor @Builder @JsonInclude(JsonInclude.Include.NON_NULL) public class ItemVO { private String name; private RequestVO request; private List<ItemVO> item; } @Data @AllArgsConstructor @NoArgsConstructor @Builder @JsonInclude(JsonInclude.Include.NON_NULL) public class RequestVO { private String method; private BodyVO body; } @Data @AllArgsConstructor @NoArgsConstructor @Builder @JsonInclude(JsonInclude.Include.NON_NULL) public class BodyVO { private String mode; private String raw; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。