Skip to content

Commit 21ca503

Browse files
author
Raphael Gachuhi
committed
changed how json wrapper serializes objects
1 parent 04e8861 commit 21ca503

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/main/java/edu/cmu/oli/content/models/persistance/JsonWrapper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ public JsonElement getJsonObject() {
3434
}
3535

3636
public JsonElement serializeJson() {
37-
JsonObject jsonObject = new JsonObject();
38-
jsonObject.add("jsonObject", jp.parse(jsonString));
39-
return jsonObject;
37+
return jp.parse(jsonString);
4038
}
4139

4240
public void setJsonObject(JsonElement jsonObject) {

src/main/java/edu/cmu/oli/content/resource/builders/OptionsWriter.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
package edu.cmu.oli.content.resource.builders;
22

3-
import com.google.gson.JsonArray;
4-
import com.google.gson.JsonElement;
5-
import com.google.gson.JsonNull;
6-
import com.google.gson.JsonObject;
3+
import com.google.gson.*;
74
import org.jdom2.Element;
85
import org.jdom2.Namespace;
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
98

109
/**
1110
* Methods for generating preference service XML.
1211
*
1312
* @author Raphael Gachuhi
1413
*/
1514
public final class OptionsWriter {
16-
15+
static final Logger log = LoggerFactory.getLogger(OptionsWriter.class);
1716
private static final String _PUBLIC_ID = "-//Carnegie Mellon University//DTD Preferences 1.0//EN";
1817
private static final String _SYSTEM_ID = "http://oli.cmu.edu/dtd/oli_preferences_1_0.dtd";
1918

@@ -49,6 +48,11 @@ public static Element preferenceSetToElement(JsonElement prefSeti, Namespace nsi
4948

5049
final Namespace ns = nsi;
5150
JsonObject prefSet = (JsonObject) prefSeti;
51+
if(prefSet.has("jsonObject")){
52+
prefSet = prefSet.getAsJsonObject("jsonObject");
53+
}
54+
55+
log.info("Preference set info: " + new Gson().toJson(prefSet));
5256
// Preference set
5357
Element setElmnt = new Element("preferences", ns);
5458

0 commit comments

Comments
 (0)