【Oracle Cloud ウェビナー】Oracle Cloud VMware Solution 最新の事例から読み解くVMwareクラウド移行のトレンド
AndroidでAPIとやり取りする場合、HttpURLConnectionとか使ってスクラッチで書いてもいいんですが、ライブラリを使ったほうが簡単に書けます。 そのような便利ライブラリの1つにAndroidQueryというのがあります。名前からわかるとおりjQueryに影響を受けており、メソッドチェーンを使って簡単にGET・POSTを実装できます。 僕ももともとAndroidQueryを使っていたんですが、今回Retforitというライブラリに置き換えたところコード量も減りとてもいい感じだったのでメモしておきます。 (1)Before After まずはBefore Afterから。 [Before: AndroidQuery] private void loadUsers() { final AjaxCallback cb = new AjaxCallback() { @Overrid
[Android] JSONの整形ってこんなに簡単にできるの!? 〜ログが劇的に見やすくなる魔法の引数〜 JSON使ってますか? モダンなアプリ開発とJSONは切っても切れない関係です。 今、この記事を見ているあなたもきっとJSONに触れたことがあるでしょう。 今回は、Android開発時に覚えておくと便利なJSONの小技を紹介します。 こんな時に使うと便利です ネットワークとの通信を行うと、レスポンスがJSONで返ってくるってことよくありませんか? そんなときは、大抵ログにレスポンスの内容を表示するものです。 この「ログ出力」するときに今回紹介する小技を使うと、ログが劇的に見やすくなってどんな値が入っているのかが一目でわかるようになります! 結局どうすればいいの? 実際なんてことないものなんで、さらっとご紹介します。 JSONを文字列に変換するときにJSONObject#toString
6. JSONやXMLのパース { “id” : 0, “name” : “tsubu”, “place_name” : “a-team” } public class Meeting { private int id; private String name; private String placeName; public void setId(int id) { this.id = id; } public void getId() { return id; } // (省略) } JSON POJO パース(デシリアイズ) シリアライズ 7. パーサーを書く public class MeetingParser { private interface Key { String ID = “id”, String NAME = “name”, String PLACE_NAME =
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く