use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class JsonConverter method getItemHintProvider.
private JSONObject getItemHintProvider(ItemHint.ValueProvider provider) throws Exception {
JSONObject result = new JSONObject();
result.put("name", provider.getName());
if (provider.getParameters() != null && !provider.getParameters().isEmpty()) {
JSONObject parameters = new JSONObject();
for (Map.Entry<String, Object> entry : provider.getParameters().entrySet()) {
parameters.put(entry.getKey(), extractItemValue(entry.getValue()));
}
result.put("parameters", parameters);
}
return result;
}
use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class JsonConverter method toJsonObject.
JSONObject toJsonObject(ItemMetadata item) throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", item.getName());
jsonObject.putOpt("type", item.getType());
jsonObject.putOpt("description", item.getDescription());
jsonObject.putOpt("sourceType", item.getSourceType());
jsonObject.putOpt("sourceMethod", item.getSourceMethod());
Object defaultValue = item.getDefaultValue();
if (defaultValue != null) {
putDefaultValue(jsonObject, defaultValue);
}
ItemDeprecation deprecation = item.getDeprecation();
if (deprecation != null) {
// backward compatibility
jsonObject.put("deprecated", true);
JSONObject deprecationJsonObject = new JSONObject();
if (deprecation.getLevel() != null) {
deprecationJsonObject.put("level", deprecation.getLevel());
}
if (deprecation.getReason() != null) {
deprecationJsonObject.put("reason", deprecation.getReason());
}
if (deprecation.getReplacement() != null) {
deprecationJsonObject.put("replacement", deprecation.getReplacement());
}
jsonObject.put("deprecation", deprecationJsonObject);
}
return jsonObject;
}
Aggregations