Skip to content

Commit

Permalink
jline-groovy: improved object to string conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed May 10, 2020
1 parent 00a46ad commit 1248c23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion demo/src/main/scripts/gron.nanorc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ color brightblue "\<[-]?[0-9]*([Ee][+-]?[0-9]+)?\>" "\<[-]?[0](\.[0-9]+)?\>"
color yellow ""(\\.|[^"])*"|'(\\.|[^'])*'|[a-zA-Z]+[a-zA-Z0-9]*"
color cyan "\<null\>"
color brightcyan "\<(true|false)\>"
color brightyellow "\"(\\"|[^"])*\"[[:space:]]*:" "'(\'|[^'])*'[[:space:]]*:" "[a-zA-Z0-9]*[[:space:]]*:"
color brightyellow "\"(\\"|[^"])*\"\s*:" "'(\'|[^'])*'\s*:" "(\[|,)\s*[a-zA-Z0-9]*\s*:"
color magenta "\\u[0-9a-fA-F]{4}|\\[bfnrt'"/\\]"
color ,green "[[:space:]]+$"
color ,red " + +| + +"
9 changes: 8 additions & 1 deletion groovy/src/main/groovy/org/jline/groovy/Utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ public class Utils {
private Utils() {}

static String toString(Object object) {
object != null ? object.toString() : 'null'
if (object == null) {
return 'null'
} else if (object instanceof Collection) {
return object.toListString()
} else if (object instanceof Map) {
return object.toMapString()
}
object.toString()
}

static Object toObject(String json) {
Expand Down

0 comments on commit 1248c23

Please sign in to comment.