Skip to content

Commit

Permalink
Fixing user pages JSON error. Fixes #158.
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Jun 12, 2018
1 parent 6b82bb7 commit 88f0405
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions service/src/main/java/com/chat/webservice/Endpoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.chat.types.user.User;
import com.chat.types.user.UserSettings;
import com.chat.types.user.Users;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.JsonNode;

import org.eclipse.jetty.http.HttpStatus;
import org.javalite.activejdbc.LazyList;
Expand Down Expand Up @@ -149,9 +151,15 @@ public static void user() {
"discussion_id", "discussion_title", "id", "modified_by_user_id", "modified_by_user_name", "table_name",
"user_id", "user_name", "role_id");

json = json.replaceAll("\\\\", "").replace("\n", "\\n");
// Converting with jackson corrects the double quote issues
Tools.JACKSON.configure(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, true);

return json;
JsonNode j = Tools.JACKSON.readTree(json);

// json = json.replaceAll("\\\\", "\n").replaceAll("\n", "\\n");


return j.toString();

});

Expand All @@ -169,7 +177,8 @@ public static void user() {
User userObj = Tools.getUserFromJWTHeader(req);
Map<String, String> vars = Tools.createMapFromReqBody(req.body());
Actions.saveUserSettings(userObj.getId(), vars.get("defaultViewTypeRadioValue"),
vars.get("defaultSortTypeRadioValue"), vars.get("defaultCommentSortTypeRadioValue"), Boolean.valueOf(vars.get("readOnboardAlert")));
vars.get("defaultSortTypeRadioValue"), vars.get("defaultCommentSortTypeRadioValue"),
Boolean.valueOf(vars.get("readOnboardAlert")));

res.status(HttpStatus.OK_200);

Expand Down

0 comments on commit 88f0405

Please sign in to comment.