LoginSignup
58

More than 5 years have passed since last update.

JSON API を使った Android 開発で便利だったツールたち

Last updated at Posted at 2014-08-27

はじめに

JSON を使ったアプリ開発で便利だった JSON 関連+αのツールを紹介します。他にもおすすめの便利ツールなどあればコメントいただけると嬉しいです。

JSON 関連

DHC - REST HTTP API Client

Chrome のエクステンションで、ブラウザ上から api のリクエストを投げて結果を見ることができます。リクエスト時のヘッダやボディも編集できます。
https://chrome.google.com/webstore/detail/dhc-rest-http-api-client/aejoelaoggembcahagimdiliamlcdmfm

オンライン版もある模様。
https://www.sprintapi.com/dhcs.html

以下は Qiita の API ( https://qiita.com/api/v1/items ) をたたいたときの画面です。

スクリーンショット 2014-08-27 20.29.40.png

PrettyJson

Sublime text の JSON 整形プラグインです。整形したいデータをエディタに貼り付けて cmd + control + j で整形できます。
https://github.com/dzhibas/SublimePrettyJson

オンラインで整形ツールを提供しているサービスもあります。
http://www.ctrlshift.net/jsonprettyprinter/

json2pojo

JSON を POJO にバインドしてくれるツール(ruby)です。JSON の構造が複雑なほど有り難みを感じます。
https://github.com/wotifgroup/json2pojo

ツール適用前

{
  "foo" : "blah",
  "baz" : 1,
  "xyz" : 2.5
}

ツール適用後

/**
 * Created by json2pojo
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class Example {

  private Double xyz;
  private Long baz;
  private String foo;

  public Double getXyz() {
    return xyz;
  }

  public void setXyz(Double xyz) {
    this.xyz = xyz;
  }

  public Long getBaz() {
    return baz;
  }

  public void setBaz(Long baz) {
    this.baz = baz;
  }

  public String getFoo() {
    return foo;
  }

  public void setFoo(String foo) {
    this.foo = foo;
  }

}

同じくオンラインで同様の機能を提供しているサービスもあります。
http://www.jsonschema2pojo.org/

その他

parcelabler

Parcelable なクラスを簡単に生成してくれるサービスです。
http://www.parcelabler.com/

コードはこちらに公開されています。
https://github.com/dallasgutauckis/parcelabler

ツール適用前

class User {
    String name;
    int age;
}

ツール適用後

class User implements Parcelable {
    String name;
    int age;

    protected User(Parcel in) {
        name = in.readString();
        age = in.readInt();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(name);
        dest.writeInt(age);
    }

    @SuppressWarnings("unused")
    public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
        @Override
        public User createFromParcel(Parcel in) {
            return new User(in);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };
}

live http headers chrome

http の ヘッダ解析ができる Chrome のエクステンションです。
https://chrome.google.com/webstore/detail/live-http-headers/iaiioopjkcekapmldfgbebdclcnpgnlo

スクリーンショット 2014-08-27 20.31.32.png

User-Agent Switcher for Chrome

Chrome 上で簡単にユーザエージェントを切り替えることができるエクステンションです。
https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg

スクリーンショット 2014-08-27 20.07.34.png

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
58