git://git.nikiroo.be
/
nikiroo-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4b3d19d
)
update from fanfix-swing
author
Niki Roo
<niki@nikiroo.be>
Tue, 12 May 2020 08:12:12 +0000
(10:12 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Tue, 12 May 2020 08:12:12 +0000
(10:12 +0200)
data/JsonIO.java
patch
|
blob
|
blame
|
history
diff --git
a/data/JsonIO.java
b/data/JsonIO.java
index fee60ce23a57b2b754fae7a1d01159af5eafb7d5..1f70f0a89adef193e3a5b43fcd719952e49fc4fa 100644
(file)
--- a/
data/JsonIO.java
+++ b/
data/JsonIO.java
@@
-16,6
+16,7
@@
public class JsonIO {
}
JSONObject json = new JSONObject();
}
JSONObject json = new JSONObject();
+
put(json, "", MetaData.class.getName());
put(json, "luid", meta.getLuid());
put(json, "title", meta.getTitle());
put(json, "", MetaData.class.getName());
put(json, "luid", meta.getLuid());
put(json, "title", meta.getTitle());
@@
-30,6
+31,7
@@
public class JsonIO {
put(json, "subject", meta.getSubject());
put(json, "type", meta.getType());
put(json, "uuid", meta.getUuid());
put(json, "subject", meta.getSubject());
put(json, "type", meta.getType());
put(json, "uuid", meta.getUuid());
+
put(json, "resume", toJson(meta.getResume()));
put(json, "tags", new JSONArray(meta.getTags()));
put(json, "resume", toJson(meta.getResume()));
put(json, "tags", new JSONArray(meta.getTags()));
@@
-52,6
+54,7
@@
public class JsonIO {
}
MetaData meta = new MetaData();
}
MetaData meta = new MetaData();
+
meta.setLuid(getString(json, "luid"));
meta.setTitle(getString(json, "title"));
meta.setAuthor(getString(json, "author"));
meta.setLuid(getString(json, "luid"));
meta.setTitle(getString(json, "title"));
meta.setAuthor(getString(json, "author"));
@@
-105,7
+108,7
@@
public class JsonIO {
}
Story story = new Story();
}
Story story = new Story();
- story.setMeta(toMetaData(getJson(json,"meta")));
+ story.setMeta(toMetaData(getJson(json,
"meta")));
story.setChapters(toListChapter(getJsonArr(json, "chapters")));
return story;
story.setChapters(toListChapter(getJsonArr(json, "chapters")));
return story;
@@
-148,6
+151,7
@@
public class JsonIO {
Chapter chap = new Chapter(getInt(json, "number", 0),
getString(json, "name"));
chap.setWords(getLong(json, "words", 0));
Chapter chap = new Chapter(getInt(json, "number", 0),
getString(json, "name"));
chap.setWords(getLong(json, "words", 0));
+
chap.setParagraphs(toListParagraph(getJsonArr(json, "paragraphs")));
return chap;
chap.setParagraphs(toListParagraph(getJsonArr(json, "paragraphs")));
return chap;
@@
-160,11
+164,13
@@
public class JsonIO {
}
JSONObject json = new JSONObject();
}
JSONObject json = new JSONObject();
+
put(json, "", Paragraph.class.getName());
put(json, "", Paragraph.class.getName());
- put(json, "type", para.getType());
put(json, "content", para.getContent());
put(json, "words", para.getWords());
put(json, "content", para.getContent());
put(json, "words", para.getWords());
+ put(json, "type", para.getType().toString());
+
return json;
}
return json;
}
@@
-193,8
+199,8
@@
public class JsonIO {
static public List<String> toListString(JSONArray array) {
if (array != null) {
List<String> values = new ArrayList<String>();
static public List<String> toListString(JSONArray array) {
if (array != null) {
List<String> values = new ArrayList<String>();
- for (
Object value : array.toList()
) {
- values.add(
value == null ? null : value.toString(
));
+ for (
int i = 0; i < array.length(); i++
) {
+ values.add(
array.getString(i
));
}
return values;
}
}
return values;
}
@@
-205,9
+211,9
@@
public class JsonIO {
static public List<Paragraph> toListParagraph(JSONArray array) {
if (array != null) {
List<Paragraph> values = new ArrayList<Paragraph>();
static public List<Paragraph> toListParagraph(JSONArray array) {
if (array != null) {
List<Paragraph> values = new ArrayList<Paragraph>();
- for (
Object value : array.toList()
) {
- values.add(
-
value instanceof Paragraph ? (Paragraph) value : null
);
+ for (
int i = 0; i < array.length(); i++
) {
+ JSONObject value = array.getJSONObject(i);
+
values.add(toParagraph(value)
);
}
return values;
}
}
return values;
}
@@
-218,8
+224,9
@@
public class JsonIO {
private static List<Chapter> toListChapter(JSONArray array) {
if (array != null) {
List<Chapter> values = new ArrayList<Chapter>();
private static List<Chapter> toListChapter(JSONArray array) {
if (array != null) {
List<Chapter> values = new ArrayList<Chapter>();
- for (Object value : array.toList()) {
- values.add(value instanceof Chapter ? (Chapter) value : null);
+ for (int i = 0; i < array.length(); i++) {
+ JSONObject value = array.getJSONObject(i);
+ values.add(toChapter(value));
}
return values;
}
}
return values;
}