Support custom newline symbol(s) for format option

This commit is contained in:
Dmitry Kolesnikov 2019-05-24 22:54:36 +03:00
parent 528d5b8253
commit 5dbb9b5f24
No known key found for this signature in database
GPG key ID: 7CB96BFD85501756
3 changed files with 22 additions and 4 deletions

View file

@ -572,8 +572,9 @@ format(JSON) -> JSON
format(JSON, Opts) -> JSON
JSON = json_text()
Opts = [option() | space | {space, N} | indent | {indent, N}]
N = pos_integer()
Opts = [option() | space | {space, N} | indent | {indent, N} | {newline, LF}]
N = pos_integer()
LF = binary()
```
`format` parses a json text (a `utf8` encoded binary) and produces a new json
@ -586,6 +587,9 @@ the option `{indent, N}` inserts a newline and `N` spaces for each level of
indentation in your json output. note that this overrides spaces inserted after
a comma. `indent` is an alias for `{indent, 1}`. the default is `{indent, 0}`
the option `{newline, LF}` defines a custom newline symbol(s).
the default is `{newline, <<$\n>>}`
raises a `badarg` error exception if input is not valid json