org.springframework.boot.configurationprocessor.json.JSONObject#put ( )源码实例Demo

下面列出了org.springframework.boot.configurationprocessor.json.JSONObject#put ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public JSONObject toJsonArray(ResourcesDescriptor metadata) throws Exception {
	JSONObject object = new JSONObject();
	JSONArray jsonArray = new JSONArray();
	for (String p : metadata.getPatterns()) {
		jsonArray.put(toJsonObject(p));
	}
	object.put("resources", jsonArray);
	return object;
}
 
public JSONObject toJsonObject(String pattern) throws Exception {
		JSONObject object = new JSONObject();
		object.put("pattern", pattern);
		return object;
//		JSONObject jsonObject = new JSONObject();
//		jsonObject.put("name", cd.getName());
//		Set<Flag> flags = cd.getFlags();
//		if (flags != null) {
//			for (Flag flag: Flag.values()) {
//				if (flags.contains(flag)) {
//					putTrueFlag(jsonObject,flag.name());
//				}
//			}
//		}
//		List<FieldDescriptor> fds = cd.getFields();
//		if (fds != null) {
//			JSONArray fieldJsonArray = new JSONArray();
//			for (FieldDescriptor fd: fds) {
//				JSONObject fieldjo = new JSONObject();
//				fieldjo.put("name", fd.getName());
//				if (fd.isAllowWrite()) {
//					fieldjo.put("allowWrite", "true");
//				}
//				fieldJsonArray.put(fieldjo);
//			}
//			jsonObject.put("fields", fieldJsonArray);
//		}
//		List<MethodDescriptor> mds = cd.getMethods();
//		if (mds != null) {
//			JSONArray methodsJsonArray = new JSONArray();
//			for (MethodDescriptor md: mds) {
//				JSONObject methodJsonObject = new JSONObject();
//				methodJsonObject.put("name", md.getName());
//				List<String> parameterTypes = md.getParameterTypes();
//					JSONArray parameterArray = new JSONArray();
//				if (parameterTypes != null) {
//					for (String pt: parameterTypes) {
//						parameterArray.put(pt);
//					}
//				}
//					methodJsonObject.put("parameterTypes",parameterArray);
//				methodsJsonArray.put(methodJsonObject);
//			}
//			jsonObject.put("methods", methodsJsonArray);
//		}
//		return jsonObject;
	}
 
源代码3 项目: spring-boot-graal-feature   文件: JsonConverter.java
public JSONObject toJsonObject(ClassDescriptor cd) throws Exception {
	JSONObject jsonObject = new JSONObject();
	jsonObject.put("name", cd.getName());
	Set<Flag> flags = cd.getFlags();
	if (flags != null) {
		for (Flag flag: Flag.values()) {
			if (flags.contains(flag)) {
				putTrueFlag(jsonObject,flag.name());
			}
		}
	}
	List<FieldDescriptor> fds = cd.getFields();
	if (fds != null) {
		JSONArray fieldJsonArray = new JSONArray();
		for (FieldDescriptor fd: fds) {
			JSONObject fieldjo = new JSONObject();
			fieldjo.put("name", fd.getName());
			if (fd.isAllowWrite()) {
				fieldjo.put("allowWrite", "true");
			}
			fieldJsonArray.put(fieldjo);
		}
		jsonObject.put("fields", fieldJsonArray);
	}
	List<MethodDescriptor> mds = cd.getMethods();
	if (mds != null) {
		JSONArray methodsJsonArray = new JSONArray();
		for (MethodDescriptor md: mds) {
			JSONObject methodJsonObject = new JSONObject();
			methodJsonObject.put("name", md.getName());
			List<String> parameterTypes = md.getParameterTypes();
				JSONArray parameterArray = new JSONArray();
			if (parameterTypes != null) {
				for (String pt: parameterTypes) {
					parameterArray.put(pt);
				}
			}
				methodJsonObject.put("parameterTypes",parameterArray);
			methodsJsonArray.put(methodJsonObject);
		}
		jsonObject.put("methods", methodsJsonArray);
	}
	return jsonObject;
}
 
源代码4 项目: spring-boot-graal-feature   文件: JsonConverter.java
private void putTrueFlag(JSONObject jsonObject, String name) throws Exception {
	jsonObject.put(name, true);
}
 
public JSONObject toPackageJsonObject(String pattern) throws Exception {
	JSONObject object = new JSONObject();
	object.put("package", pattern);
	return object;
}
 
public JSONObject toClassJsonObject(String pattern) throws Exception {
	JSONObject object = new JSONObject();
	object.put("class", pattern);
	return object;
}
 
源代码7 项目: sophia_scaffolding   文件: MyFallbackProvider.java
@Override
public ClientHttpResponse fallbackResponse(String route, Throwable cause) {
    return new ClientHttpResponse() {
        @Override
        public HttpStatus getStatusCode() throws IOException {
            return HttpStatus.OK;
        }

        @Override
        public int getRawStatusCode() throws IOException {
            return 200;
        }

        @Override
        public String getStatusText() throws IOException {
            return "OK";
        }

        @Override
        public void close() {

        }

        @Override
        public InputStream getBody() {
            SophiaHttpStatus resultEnum = SophiaHttpStatus.SERVER_TIMEOUT;
            String data = "";
            JSONObject jsonObject = new JSONObject();
            try {
                jsonObject.put("code", resultEnum.getCode());
                jsonObject.put("msg", resultEnum.getMessage());
                jsonObject.put("data", data);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            data = jsonObject.toString();
            logger.error(data);
            return new ByteArrayInputStream(data.getBytes());
        }

        @Override
        public HttpHeaders getHeaders() {
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_JSON);
            return headers;
        }
    };
}
 
源代码8 项目: sophia_scaffolding   文件: MyFallbackProvider.java
@Override
public ClientHttpResponse fallbackResponse(String route, Throwable cause) {
    return new ClientHttpResponse() {
        @Override
        public HttpStatus getStatusCode() throws IOException {
            return HttpStatus.OK;
        }

        @Override
        public int getRawStatusCode() throws IOException {
            return 200;
        }

        @Override
        public String getStatusText() throws IOException {
            return "OK";
        }

        @Override
        public void close() {

        }

        @Override
        public InputStream getBody() {
            SophiaHttpStatus resultEnum = SophiaHttpStatus.SERVER_TIMEOUT;
            String data = "";
            JSONObject jsonObject = new JSONObject();
            try {
                jsonObject.put("code", resultEnum.getCode());
                jsonObject.put("msg", resultEnum.getMessage());
                jsonObject.put("data", data);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            data = jsonObject.toString();
            logger.error(data);
            return new ByteArrayInputStream(data.getBytes());
        }

        @Override
        public HttpHeaders getHeaders() {
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_JSON);
            return headers;
        }
    };
}
 
源代码9 项目: sophia_scaffolding   文件: MyFallbackProvider.java
@Override
public ClientHttpResponse fallbackResponse(String route, Throwable cause) {
    return new ClientHttpResponse() {
        @Override
        public HttpStatus getStatusCode() throws IOException {
            return HttpStatus.OK;
        }

        @Override
        public int getRawStatusCode() throws IOException {
            return 200;
        }

        @Override
        public String getStatusText() throws IOException {
            return "OK";
        }

        @Override
        public void close() {

        }

        @Override
        public InputStream getBody() {
            SophiaHttpStatus resultEnum = SophiaHttpStatus.SERVER_TIMEOUT;
            String data = "";
            JSONObject jsonObject = new JSONObject();
            try {
                jsonObject.put("code", resultEnum.getCode());
                jsonObject.put("msg", resultEnum.getMessage());
                jsonObject.put("data", data);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            data = jsonObject.toString();
            logger.error(data);
            return new ByteArrayInputStream(data.getBytes());
        }

        @Override
        public HttpHeaders getHeaders() {
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_JSON);
            return headers;
        }
    };
}