Wrong output produced for special characters
When using the method ComplexElement.makeStringElement(String value), more special characters need to be checked for.
Currently only [,{,\,",\n are searched for, but the full list includes :,,,#,[,{,",\n
Furthermore, it should be checked for null and blank values.
Suggested fix in Helpers.jrag:
// --- helper methods for put/add ---
protected SimpleElement ComplexElement.makeStringElement(String value) {
+ if (value == null || value.equals("null")) {
+ return StringElement.of("null");
+ }
+ if (value.isBlank()) {
+ return StringElement.of(value);
+ }
// simple test, check for special characters
- return containsAny(value, "[{\"\n") ?
+ return containsAny(value, ":#,[{\"\n") ?
StringElement.of(value.replace("\n", "\\n").replace("\"", "\\\"")) :
ValueElement.of(value);
}