amar1104
08/12/2024, 6:50 PM{{sortBy users 'address.city'}}
where user = {"name": "john", "address":{"city":"London","country":"ENG"},"age":36}, how to get the value of address.city
from the object?
public Object apply(List<?> list, Options options) throws IOException {
if (list == null || list.isEmpty()) {
return emptyList();
}
final String sortBy = options.params[0].toString();
final ArrayList<Object> resultList = new ArrayList<>(list)
resultList.sort((o1, o2) -> {
try {
//How to get these values?
String value1 = o1.get(property).asText();
String value2 = o2.get(property).asText();
return value1.compareTo(value2);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
return resultList;
}
Lee Turner
08/14/2024, 8:04 AMuser
is a json string could you parse the json into an object of your creation?amar1104
08/17/2024, 12:56 PM