Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1001933 // makePostData

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3829L/22K).

sS makePostData(Map map) {
  new StringBuilder buf;
  for (Map.Entry<O, O> e : castMapToMapO(map).entrySet()) {
    S key = cast e.getKey();
    O val = e.getValue();
    if (val != null) {
      S value = str(val);
      if (nempty(buf)) buf.append("&");
      buf.append(urlencode(key)).append("=").append(urlencode(/*escapeMultichars*/(value)));
    }
  }
  ret str(buf);
}

sS makePostData(O... params) {
  new StringBuilder buf;
  int n = l(params);
  for (int i = 0; i+1 < n; i += 2) {
    S key = cast params[i];
    O val = params[i+1];
    if (val != null) {
      S value = str(val);
      if (nempty(buf)) buf.append("&");
      buf.append(urlencode(key)).append("=").append(urlencode(/*escapeMultichars*/(value)));
    }
  }
  ret str(buf);

}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1001933
Snippet name: makePostData
Eternal ID of this version: #1001933/4
Text MD5: 53d2bbc38697893e2605c645df1ded79
Transpilation MD5: ce18b3da542e804a68fd936faeb21b29
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-24 18:11:46
Source code size: 785 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 597 / 2157
Version history: 3 change(s)
Referenced in: [show references]