kwin commented on a change in pull request #1: Sling-7346-Json response
converting response property value to string even if it is json object
URL:
https://github.com/apache/sling-org-apache-sling-servlets-post/pull/1#discussion_r159607218
##########
File path: src/main/java/org/apache/sling/servlets/post/JSONResponse.java
##########
@@ -103,9 +104,13 @@ JsonObject getJson() {
JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
for (Map.Entry<String, Object> entry : json.entrySet()) {
if (entry.getValue() != null) {
- jsonBuilder.add(entry.getKey(), entry.getValue().toString());
- }
- else {
+ try {
Review comment:
I think instead of buffering the values in a map, we should directly use the
according add methods in
https://docs.oracle.com/javaee/7/api/javax/json/JsonObjectBuilder.html and
throw an exception if an invalid type is passed to `setProperty`. That way we
create the JSON Object on the fly and make sure that we don't accept any
invalid value types.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services