Skip to content

Instantly share code, notes, and snippets.

@yhishi
yhishi / Insert.java
Last active September 25, 2017 14:43
gson.fromJson
import com.google.gson.Gson;
/**
* 登録機能などでクライアント側からのJSON形式のデータを
* Javaオブジェクトに変換する
* ※inputは連想配列形式のJSONデータ
*/
// 入力複数データをまとめて取得
String input = request.getParameter("input");
@yhishi
yhishi / Search.java
Last active September 25, 2017 14:42
gson.toJson
import com.google.gson.Gson;
/**
* 検索機能などでDBから値を取得し、クライアント側にリストを返すとき、
* Javaオブジェクトでは返せないため、JSON形式に変換する
* ※dblistはDBから取得した<ArrayList<String>>
*/
// Gsonオブジェクトを作成
Gson gson = new Gson();
-- 認証情報
AccessToken = 'Bearer ???=' -- ???に自分のChannel Access Token 変更箇所1
-- 受信メッセージから送信メッセージを構築
body = json.parse(request.body)
reply = body.events[1].replyToken -- 返信先
inBoxMessage = body.events[1].message.text -- 受信メッセージ
-- 返答パターン
-- resTable['ここに書いたキーワードがLINEで入力されると'] = 'これが返されます'