(Object parameters)
| 308 | } |
| 309 | |
| 310 | public static String urlencodeNested(Object parameters) { |
| 311 | Map<String, Object> params = (Map<String, Object>) parameters; |
| 312 | List<String> keys = new ArrayList<>(params.keySet()); |
| 313 | List<String> parts = new ArrayList<>(); |
| 314 | |
| 315 | for (String key : keys) { |
| 316 | Object value = params.get(key); |
| 317 | if (value instanceof Map<?, ?> m) { |
| 318 | Map<String, Object> inner = (Map<String, Object>) m; |
| 319 | for (String k2 : inner.keySet()) { |
| 320 | Object v2 = inner.get(k2); |
| 321 | String finalValue = String.valueOf(v2); |
| 322 | if (v2 instanceof Boolean) { |
| 323 | finalValue = finalValue.toLowerCase(Locale.ROOT); |
| 324 | } |
| 325 | // qs.stringify({encodeValuesOnly:true}) emits `key[subkey]=value` |
| 326 | // with the brackets unencoded and the value URL-encoded |
| 327 | // using qs's stricter set (e.g. `(` `)` → `%28` `%29`). |
| 328 | // Use urlEncode (java.net.URLEncoder) for both name segments |
| 329 | // and the value so brackets stay literal but parens encode. |
| 330 | parts.add(urlEncode(key) + "[" + urlEncode(k2) + "]" + "=" + urlEncode(finalValue)); |
| 331 | } |
| 332 | } else { |
| 333 | // Use urlEncode (qs-style stricter set: encodes `()`, `[]`, |
| 334 | // matches Python qs.stringify default and what kraken's |
| 335 | // signature-included body expects). |
| 336 | parts.add(urlEncode(key) + "=" + urlEncode(String.valueOf(value))); |
| 337 | } |
| 338 | } |
| 339 | return String.join("&", parts); |
| 340 | } |
| 341 | |
| 342 | public static String urlencode(Object parameters2, boolean... sortParams) { |
| 343 | boolean sort = (sortParams.length > 0) ? sortParams[0] : false; |
no test coverage detected