code: public void setMode(ArrayList<Long> tokens, String mode){
          JSONObject jobj = new JSONObject();
          try {
              // int a[] = {256265, 408065, 779521, 738561, 177665, 25601};
              JSONArray list = new JSONArray();
              JSONArray listMain = new JSONArray();
              listMain.put(0, mode);
              for(int i=0; i< tokens.size(); i++){
                  list.put(i, tokens.get(i));
              }
              listMain.put(1, list);
              jobj.put("a", mSetMode);
              jobj.put("v", listMain);
              for(int i = 0; i < tokens.size(); i++){
                  modeMap.put(tokens.get(i), mode);
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
          if(ws != null) {
              ws.sendText(jobj.toString());
          }
      }
docs: Setting different modes for an arraylist of tokens.
  @param tokens an arraylist of tokens
  @param mode the mode that needs to be set. Scroll up to see different
  kind of modes