use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class JsonConverter method putHintValue.
private void putHintValue(JSONObject jsonObject, Object value) throws Exception {
Object hintValue = extractItemValue(value);
jsonObject.put("value", hintValue);
}
use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class JsonMarshaller method read.
public ConfigurationMetadata read(InputStream inputStream) throws Exception {
ConfigurationMetadata metadata = new ConfigurationMetadata();
JSONObject object = new JSONObject(toString(inputStream));
JSONArray groups = object.optJSONArray("groups");
if (groups != null) {
for (int i = 0; i < groups.length(); i++) {
metadata.add(toItemMetadata((JSONObject) groups.get(i), ItemType.GROUP));
}
}
JSONArray properties = object.optJSONArray("properties");
if (properties != null) {
for (int i = 0; i < properties.length(); i++) {
metadata.add(toItemMetadata((JSONObject) properties.get(i), ItemType.PROPERTY));
}
}
JSONArray hints = object.optJSONArray("hints");
if (hints != null) {
for (int i = 0; i < hints.length(); i++) {
metadata.add(toItemHint((JSONObject) hints.get(i)));
}
}
return metadata;
}
use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class JsonMarshaller method toValueHint.
private ItemHint.ValueHint toValueHint(JSONObject object) throws Exception {
Object value = readItemValue(object.get("value"));
String description = object.optString("description", null);
return new ItemHint.ValueHint(value, description);
}
use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class JsonMarshaller method toItemMetadata.
private ItemMetadata toItemMetadata(JSONObject object, ItemType itemType) throws Exception {
String name = object.getString("name");
String type = object.optString("type", null);
String description = object.optString("description", null);
String sourceType = object.optString("sourceType", null);
String sourceMethod = object.optString("sourceMethod", null);
Object defaultValue = readItemValue(object.opt("defaultValue"));
ItemDeprecation deprecation = toItemDeprecation(object);
return new ItemMetadata(itemType, name, null, type, sourceType, sourceMethod, description, defaultValue, deprecation);
}
use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class JsonMarshaller method toItemHint.
private ItemHint toItemHint(JSONObject object) throws Exception {
String name = object.getString("name");
List<ItemHint.ValueHint> values = new ArrayList<>();
if (object.has("values")) {
JSONArray valuesArray = object.getJSONArray("values");
for (int i = 0; i < valuesArray.length(); i++) {
values.add(toValueHint((JSONObject) valuesArray.get(i)));
}
}
List<ItemHint.ValueProvider> providers = new ArrayList<>();
if (object.has("providers")) {
JSONArray providersObject = object.getJSONArray("providers");
for (int i = 0; i < providersObject.length(); i++) {
providers.add(toValueProvider((JSONObject) providersObject.get(i)));
}
}
return new ItemHint(name, values, providers);
}
Aggregations