Libraryless. Click here for Pure Java version (4258L/24K).
1 | // TODO: handle null values |
2 | sS replaceDollarVars_js(S s, O... _) { |
3 | //ret replaceDollarVars_withCustomToString(s, o -> jsonEncode_extended(o), _); |
4 | MapSO vars = paramsToMap_withNulls(_); |
5 | if (empty(vars)) ret s; |
6 | var vars2 = mapKeys dropDollarPrefix(vars); |
7 | |
8 | ret replaceDollarVars_dyn(s, var -> { |
9 | if (!vars2.containsKey(var)) null; |
10 | O value = vars2.get(var); |
11 | ret jsonEncode_extended(value); |
12 | }); |
13 | } |
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: | 192 / 289 |
Version history: | 9 change(s) |
Referenced in: | [show references] |