Skip to content

Commit eacdc41

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

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

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

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

3-
import com.google.gson.*;
3+
import com.google.gson.JsonArray;
4+
import com.google.gson.JsonElement;
5+
import com.google.gson.JsonNull;
6+
import com.google.gson.JsonObject;
47
import org.jdom2.Element;
58
import org.jdom2.Namespace;
69
import org.slf4j.Logger;
@@ -48,11 +51,12 @@ public static Element preferenceSetToElement(JsonElement prefSeti, Namespace nsi
4851

4952
final Namespace ns = nsi;
5053
JsonObject prefSet = (JsonObject) prefSeti;
51-
if(prefSet.has("jsonObject")){
52-
prefSet = prefSet.getAsJsonObject("jsonObject");
54+
// Preferences
55+
JsonArray preferences = prefSet.getAsJsonArray("preferences");
56+
if (preferences == null) {
57+
return null;
5358
}
5459

55-
log.info("Preference set info: " + new Gson().toJson(prefSet));
5660
// Preference set
5761
Element setElmnt = new Element("preferences", ns);
5862

@@ -61,16 +65,12 @@ public static Element preferenceSetToElement(JsonElement prefSeti, Namespace nsi
6165
setElmnt.setAttribute("guid", prefSet.get("@guid").getAsString());
6266
}
6367

64-
// Preferences
65-
JsonArray preferences = prefSet.getAsJsonArray("preferences");
66-
if (preferences != null) {
67-
preferences.forEach((val) -> {
68-
Element element = preferenceToElement(val, ns);
69-
if (element != null) {
70-
setElmnt.addContent(element);
71-
}
72-
});
73-
}
68+
preferences.forEach((val) -> {
69+
Element element = preferenceToElement(val, ns);
70+
if (element != null) {
71+
setElmnt.addContent(element);
72+
}
73+
});
7474

7575
return setElmnt;
7676
}

0 commit comments

Comments
 (0)