+ // no images
+ static public JSONObject toJson(Paragraph para) {
+ if (para == null) {
+ return null;
+ }
+
+ JSONObject json = new JSONObject();
+
+ put(json, "", Paragraph.class.getName());
+ put(json, "content", para.getContent());
+ put(json, "words", para.getWords());
+
+ put(json, "type", para.getType().toString());
+
+ return json;
+ }
+
+ /**
+ * // no images
+ *
+ * @param json
+ *
+ * @return
+ *
+ * @throws JSONException
+ * when it cannot be converted
+ */
+ static public Paragraph toParagraph(JSONObject json) {
+ if (json == null) {
+ return null;
+ }
+
+ Paragraph para = new Paragraph(
+ ParagraphType.valueOf(getString(json, "type")),
+ getString(json, "content"), getLong(json, "words", 0));
+
+ return para;
+ }
+