差分発生行の前後
無視リスト:
更新日時:
2014/04/21 18:00:35 (10 年 前)
更新者:
kozaki
ログメッセージ:

JSON出力が上手くいかないので,独自メソッドを導入.

ファイル:
1 変更

凡例:

変更なし
追加
削除
  • BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/OWL/Path.java

    r66 r68  
    44 
    55import org.json.JSONArray; 
     6import org.json.JSONException; 
    67import org.json.JSONObject; 
    78 
     
    2829        public JSONObject toJSON() { 
    2930                JSONObject obj = new JSONObject(); 
    30                 obj.put("startClassURI", startClass); 
     31                try { 
     32                        obj.put("startClassURI", startClass); 
    3133                obj.put("width", width); 
    3234                if (classLinks != null && classLinks.size() != 0) { 
     
    3537                                classLinkObjs[i] = classLinks.get(i).toJSON(); 
    3638                        } 
    37                         JSONArray array = new JSONArray(classLinkObjs); 
     39                        //繧ィ繝ゥ繝シ縺悟�繧九�縺ァ荳玖ィ倥�騾壹j菫ョ豁」 
     40                        JSONArray array = new JSONArray(); 
     41                        //JSONArray array = new JSONArray(classLinkObjs); 
    3842                        obj.put("classLinks", array); 
    3943                } 
     44                } catch (JSONException e) { 
     45                        // TODO Auto-generated catch block 
     46                        e.printStackTrace(); 
     47                        System.out.println(e.toString()); 
     48                } 
     49                 
    4050                return obj; 
    4151        } 
     
    4555        } 
    4656 
     57        public String toJSONString2(){ 
     58                String json_str=""; 
     59                json_str+="{\"startClassURI\":\""+ startClass+"\","; 
     60                json_str+="\"width\":"+width+","; 
     61                 
     62                if (classLinks != null && classLinks.size() != 0) { 
     63                        json_str+="\"classLinks\":["; 
     64                         
     65                        JSONObject[] classLinkObjs = new JSONObject[classLinks.size()]; 
     66                        for (int i = 0; i < classLinks.size(); i++) { 
     67                                if(i>0){json_str += "," ;} 
     68                                json_str+= classLinks.get(i).toJSONString2(); 
     69                        } 
     70                        json_str+="]"; 
     71                } 
     72                json_str+="}"; 
     73                 
     74                return json_str; 
     75        } 
     76 
     77         
    4778        public String getStartClass() { 
    4879                return startClass;