Java Code Examples for org.springframework.boot.configurationprocessor.json.JSONObject#put()
The following examples show how to use
org.springframework.boot.configurationprocessor.json.JSONObject#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourcesJsonConverter.java From spring-boot-graal-feature with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: ResourcesJsonConverter.java From spring-boot-graal-feature with Apache License 2.0 | 4 votes |
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; }
Example 3
Source File: JsonConverter.java From spring-boot-graal-feature with Apache License 2.0 | 4 votes |
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; }
Example 4
Source File: JsonConverter.java From spring-boot-graal-feature with Apache License 2.0 | 4 votes |
private void putTrueFlag(JSONObject jsonObject, String name) throws Exception { jsonObject.put(name, true); }
Example 5
Source File: InitializationJsonConverter.java From spring-boot-graal-feature with Apache License 2.0 | 4 votes |
public JSONObject toPackageJsonObject(String pattern) throws Exception { JSONObject object = new JSONObject(); object.put("package", pattern); return object; }
Example 6
Source File: InitializationJsonConverter.java From spring-boot-graal-feature with Apache License 2.0 | 4 votes |
public JSONObject toClassJsonObject(String pattern) throws Exception { JSONObject object = new JSONObject(); object.put("class", pattern); return object; }
Example 7
Source File: MyFallbackProvider.java From sophia_scaffolding with Apache License 2.0 | 4 votes |
@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; } }; }
Example 8
Source File: MyFallbackProvider.java From sophia_scaffolding with Apache License 2.0 | 4 votes |
@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; } }; }
Example 9
Source File: MyFallbackProvider.java From sophia_scaffolding with Apache License 2.0 | 4 votes |
@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; } }; }