私はjson、googleapisに非常に慣れていません。だからご案内ください。
Restfulを介してgoogleカスタムserchapiを使用するアプリケーションを「JAVA」で作成しようとしています。私はjsonを学び始め、[リンク] http://code.google.com/apis/customsearch/v1/overview.htmlを通過しました。コードを書きたかったのです。
これは、Googleの検索のjsonを示しています:
http ://code.google.com/apis/customsearch/v1/reference.html#method_search_cse_list
参照はhttp://code.google.com/apis/customsearch/v1/reference.htmlです
参照から、このCustomSearchのどのフィールドがString、int、またはその他のデータ型になるかを見つけました。また、すべてのオブジェクトの構造も定義されています。
しかし、私はいくつかのデータ型で問題に直面しています:
items.title array The title of the search result, in plain text.
items.snippet array The snippet of the search result, in plain text.
items.pagemap object Contains pagemap information for this search result.
items.pagemap.value array Pagemap information, keyed by the name of this pagemap.
items.pagemap.value.value object The actual pagemap information.
クラスでそれらをどのように定義しますか。タイトル文字列または文字とはどのような配列であり、このページマップは慣例であるか、どのサイトでも独自のタグを付けることができます。
//クラスCustomSearch
public class CustomSearch {
public URL getURL() throws MalformedURLException{
return url.getURL();
}
@Key ("items") ArrayList<SearchResult> results;
private @Key SearchURL url;
private @Key Query queries;
}
// クラス
class SearchResult {
public SearchResult(){
}
public String getTitle(){
return title;
}
public String getLink(){
return link;
}
public String getSnippet(){
return snippet;
}
private @Key String title; // is this right ?
private @Key String htmlTitle;
private @Key String link;
private @Key String snippet; // is this right ?
private @Key String htmlSnippet;
}