public static class JSON { private String buffer; HashMap data; /* public JSON(String url){ // data = parse("\"aa,bb\":c,{\"a,b.\",c}:d"); // data = parse("\"status\":{\"in_reply_to_screen_name\":null,\"truncated\":false,\"in_reply_to_status_id_str\":null,\"activities\":{\"retweeters_count\":\"0\",\"retweeters\":[],\"favoriters\":[],\"favoriters_count\":\"0\",\"repliers\":[],\"repliers_count\":\"0\"},\"retweeted\":false,\"created_at\":\"Thu Dec 01 15:10:59 +0000 2011\",\"in_reply_to_user_id_str\":null,\"entities\":{\"user_mentions\":[],\"urls\":[],\"hashtags\":[]},\"geo\":null,\"id_str\":\"142259401795977216\",\"contributors\":null,\"place\":null,\"coordinates\":null,\"in_reply_to_user_id\":null,\"source\":\"web\",\"retweet_count\":0,\"in_reply_to_status_id\":null,\"favorited\":false,\"id\":142259401795977216,\"text\":\"\\u30cf\\u30a1\\u30a4\\uff01\\u30de\\u30c3\\u30ae\\u30e7\\u304c\\u5927\\u597d\\u304d\\u306a\\u9ed2\\u6708\\u84bc\\u3067\\u3059\\u3001\\u3053\\u3093\\u3070\\u3093\\u306f\"}"); // data = parse("[{\"follow_request_sent\":null,\"geo_enabled\":false,\"protected\":false,\"verified\":false,\"profile_sidebar_border_color\":\"C0DEED\",\"name\":\"\\u9ed2\\u6708\\u3000\\u84bc\",\"show_all_inline_media\":false,\"created_at\":\"Wed Nov 09 15:14:54 +0000 2011\",\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1667905991\\/_____normal.jpg\",\"listed_count\":1,\"profile_use_background_image\":true,\"utc_offset\":-36000,\"description\":\"\\u5b66\\u6821\\u5c02\\u7528\\u517c\\u5c31\\u6d3b\\u5c02\\u7528\\u57a2\\u3002\\r\\n\\u30d5\\u30a9\\u30ed\\u30fc\\u304a\\u6c17\\u8efd\\u306b\\u3069\\u3046\\u305e^o^\\r\\n\\u672c\\u57a2\\u3010tukuyomi903\\u3011\\u3000\\u898f\\u5236\\u57a2\\u3010tukuyomi_0031\\u3011\",\"time_zone\":\"Hawaii\",\"profile_text_color\":\"333333\",\"screen_name\":\"ku62ki_night\",\"contributors_enabled\":false,\"lang\":\"ja\",\"profile_background_image_url\":\"http:\\/\\/a0.twimg.com\\/images\\/themes\\/theme1\\/bg.png\",\"followers_count\":18,\"profile_image_url\":\"http:\\/\\/a3.twimg.com\\/profile_images\\/1667905991\\/_____normal.jpg\",\"id_str\":\"408538653\",\"status\":{\"in_reply_to_screen_name\":null,\"truncated\":false,\"in_reply_to_status_id_str\":null,\"activities\":{\"retweeters_count\":\"0\",\"retweeters\":[],\"favoriters\":[],\"favoriters_count\":\"0\",\"repliers\":[],\"repliers_count\":\"0\"},\"retweeted\":false,\"created_at\":\"Thu Dec 01 15:10:59 +0000 2011\",\"in_reply_to_user_id_str\":null,\"entities\":{\"user_mentions\":[],\"urls\":[],\"hashtags\":[]},\"geo\":null,\"id_str\":\"142259401795977216\",\"contributors\":null,\"place\":null,\"coordinates\":null,\"in_reply_to_user_id\":null,\"source\":\"web\",\"retweet_count\":0,\"in_reply_to_status_id\":null,\"favorited\":false,\"id\":142259401795977216,\"text\":\"\\u30cf\\u30a1\\u30a4\\uff01\\u30de\\u30c3\\u30ae\\u30e7\\u304c\\u5927\\u597d\\u304d\\u306a\\u9ed2\\u6708\\u84bc\\u3067\\u3059\\u3001\\u3053\\u3093\\u3070\\u3093\\u306f\"},\"profile_link_color\":\"0084B4\",\"default_profile_image\":false,\"friends_count\":40,\"location\":\"3gfh\",\"default_profile\":true,\"profile_background_color\":\"C0DEED\",\"is_translator\":false,\"statuses_count\":2,\"profile_background_tile\":false,\"url\":null,\"id\":408538653,\"following\":null,\"notifications\":null,\"profile_background_image_url_https\":\"https:\\/\\/si0.twimg.com\\/images\\/themes\\/theme1\\/bg.png\",\"favourites_count\":0,\"profile_sidebar_fill_color\":\"DDEEF6\"}]"); // data = parse("{\"next_cursor\":0,\"previous_cursor\":0,\"ids\":[408538653,185281571,270746283,15363470,59594023,53150496,409052416,282565721,44064903,361012283,89402212,384165195,94270954,408268609,405392619,368767585,334595914,303234498,397316763,137716809,216002852,128480546,149832230,372195780,61978982,38430396,387013815,283895499,384142390,385838385,385839537,320745696,385823732,148770965,191766566,269783190,214763339,329643106,200434822,337612716,348321450,384072543,379664554,377136509,316203891,349430662,72461205,145586988,258293737,217241811,359517037,235062433,360440236,348247803,352876179,311931910,321820607,13760592,277518284,128493093,210625335,84774012,304209787,165323375,310363695,16056152,242133006,163314211,262993173,146730571,249004705,112387945,276787300,260980446,169996210,257881147,252099827,129544893,155827498,216037464,134695070,20574396,227746455,214850916,132813392,194027580,227696952,218378931,223503185,141927068,11328252,6756242,144395850,6170122,191710063,96383684,39757226,46103645,15797402,170672806,130831754,49721456,159438585,89890747,15154400,6437392,43288739,152988826,100875782,137605061,149875418,124375502,137208804,66948907,107560088,136206237,82299228,113267269,132054232,108529906,7241712,103200132,57338890,41541278,124506755,100195151,122933289,113556560,116688627,44841641,11591742,91634074,14928503,110380234,4620311,74950163,60216991,108553792,94895819,67754116,107412474,96438031,71809976,105046696,17231707,14214957,79722455,75923171,95481495,102301693,96329928,94513558,18094482,97128140,80627159,13275402,90385206,72514009,6054802,16065433,81053380,94250877],\"next_cursor_str\":\"0\",\"previous_cursor_str\":\"0\"}"); load(url); } */ public static String trimArc(String str,char[] arc){ StringBuffer sb = new StringBuffer(str); while(sb.length()!=0 && sb.charAt(0)==arc[0] && sb.charAt(sb.length()-1)==arc[1]){ sb.deleteCharAt(0); sb.deleteCharAt(sb.length()-1); } return new String(sb); } private char[] otherArc(char c){ char[][] arcs = {{'\"','\"'},{'[',']'},{'{','}'}}; for(int cnt=0;cnt parse(String str){ StringBuffer sb = new StringBuffer(trimArc(trimArc(str,new char[]{'[',']'}),new char[]{'{','}'})); char[][] codes = {{',',(char)0x07},{':',(char)0x08}}; Vector[] indexes = new Vector[codes.length]; for(int cnt=0;cnt(); } char[] o_arc = {(char)-1,(char)-1}; int o_arc_count = 1; for(int cnt=0;cnt data = new HashMap(); String[] parts = (new String(sb)).split(","); for(int cnt=0;cnt "+trimArc(key_value[1],new char[]{'\"','\"'})); } return data; } public HashMap load(String url){ try{ BufferedReader br = new BufferedReader(new InputStreamReader((new URL(url)).openStream())); String ln = null; buffer = new String(); while(null!=(ln=br.readLine())){ if(buffer.length()!=0){ buffer += "\n"; } buffer += ln; } br.close(); data = parse(buffer); return data; }catch(Exception e){ // e.printStackTrace(); } return null; } public String toString(){ return buffer; } public String get(String key){ return data.get(key); } }