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

13
LINES

< > BotCompany Repo | #1032319 // replaceDollarVars_js - now handles all kinds of JSON structures (strings, ints, maps, lists etc)

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

Libraryless. Click here for Pure Java version (4258L/24K).

// TODO: handle null values
sS replaceDollarVars_js(S s, O... _) {
  //ret replaceDollarVars_withCustomToString(s, o -> jsonEncode_extended(o), _);
  MapSO vars = paramsToMap_withNulls(_);
  if (empty(vars)) ret s;
  var vars2 = mapKeys dropDollarPrefix(vars);
  
  ret replaceDollarVars_dyn(s, var -> {
    if (!vars2.containsKey(var)) null;
    O value = vars2.get(var);
    ret jsonEncode_extended(value);
  });
}

Author comment

Began life as a copy of #1032133

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032319
Snippet name: replaceDollarVars_js - now handles all kinds of JSON structures (strings, ints, maps, lists etc)
Eternal ID of this version: #1032319/10
Text MD5: d0b93289f9b3ba14cde3497b28637057
Transpilation MD5: d124d0bb776a1033e59f93c6877a421d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-04 02:58:44
Source code size: 428 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 191 / 287
Version history: 9 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1030949 - Transpiler output of #1031393