@@ -26,7 +26,7 @@ public NoticeCategory(String name, String content) {
2626 public NoticeCategory (String name , ArrayList <NoticeCategory > subcategories ) {
2727 this .name = name ;
2828 this .subcategories = subcategories ;
29- content = "" ;
29+ content = null ;
3030 }
3131
3232 public String getName () {
@@ -56,7 +56,8 @@ public void setContent(String content) {
5656 public JSONObject toJson () throws JSONException {
5757 JSONObject obj = new JSONObject ();
5858 obj .put ("name" , name );
59- obj .put ("content" , content );
59+ if (content !=null ) obj .put ("content" , content );
60+ else obj .put ("content" , "" );
6061 ArrayList vect = new ArrayList <JSONObject >();
6162 if (subcategories !=null ) for (NoticeCategory subcategory : subcategories ) vect .add (subcategory .toJson ());
6263 obj .put ("subcategories" , new JSONArray (vect ));
@@ -65,16 +66,18 @@ public JSONObject toJson() throws JSONException {
6566
6667 public void fromJson (JSONObject jsobj ) throws JSONException {
6768 name = jsobj .getString ("name" );
69+ content = jsobj .getString ("content" );
70+ if (content == "" ) content = null ;
6871 JSONArray arr = jsobj .getJSONArray ("subcategories" );
6972 subcategories = new ArrayList <NoticeCategory >();
70- NoticeCategory category = new NoticeCategory () ;
73+ NoticeCategory category ;
7174 if (arr .length ()!=0 ) {
7275 for (int i = 0 ; i <arr .length (); i ++) {
76+ category = new NoticeCategory ();
7377 category .fromJson (arr .getJSONObject (i ));
7478 subcategories .add (category );
7579 }
7680 }
7781 else subcategories = null ;
78- content = jsobj .getString ("content" );
7982 }
8083}
0 commit comments