Return a quoted JSON string representing the specified Java object. @param obj Java object to be represented @return quoted JSON string
(Object obj)
| 445 | * @return quoted JSON string |
| 446 | */ |
| 447 | private String asString(Object obj) { |
| 448 | StringBuilder toReturn = new StringBuilder("\""); |
| 449 | |
| 450 | String.valueOf(obj) |
| 451 | .chars() |
| 452 | .forEach( |
| 453 | i -> { |
| 454 | String escaped = ESCAPES.get(i); |
| 455 | if (escaped != null) { |
| 456 | toReturn.append(escaped); |
| 457 | } else { |
| 458 | toReturn.append((char) i); |
| 459 | } |
| 460 | }); |
| 461 | |
| 462 | toReturn.append('"'); |
| 463 | |
| 464 | return toReturn.toString(); |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * Get a reference to a method of the specified name with no argument in the indicated class or |