0
從應對複雜的JSON所有值我試圖從 http://www.google.com/dictionary/json?callback=dic&q=keyword&sl=en&tl=en&restrict=pr%2Cde&client=te提取的java
提取所有的值,我想用GSON,但我不能想出什麼用它做。
是否有任何與jericohtml解析器類似的東西可以簡單地提取所有值?
另外,我需要使用java。 我可以檢索JSON,但它不是定期格式化(我的意思是一行一行寫的)
感謝
URL u=new URL(url);
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/atom+xml");
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 5.2; rv:21.0) Gecko/20100101 Firefox/21.0");
BufferedReader br=new BufferedReader(new InputStreamReader(conn.getInputStream()));
String temp=br.readLine();
String strJson=temp.substring("dic(".length(),temp.length()-",200,null)".length());
System.out.println(strJson);
顯示你的努力.. – commit