/**
* Gets a JSONObject representation of a BookMeta. Book and Quills books will have a pages key, while
* finished, written, books will also have an author and title key.
*
* @param meta The BookMeta to serialize
* @return A JSON Representation of the give BookMeta
*/
public static JSONObject serializeBookMeta(BookMeta meta) {
try {
JSONObject root = new JSONObject();
if (meta.hasTitle())
root.put("title", meta.getTitle());
if (meta.hasAuthor())
root.put("author", meta.getAuthor());
if (meta.hasPages()) {
String[] pages = meta.getPages().toArray(new String[]{});
root.put("pages", pages);
}
return root;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
BookSerialization.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:NexusInventory
作者:
评论列表
文章目录