Releases: emqx/hocon
Releases · emqx/hocon
0.42.0
Non-backward compatible refactoring based on 0.41.0 for triple-quote strings.
- Immediate quote before triple-quote is invalid sytax.
""""a""""
is invalid because there are 4 closing quotes instead of three. See workarounds below.
- Multiline strings allow indentation (spaces, not tabs).
If~\n
(or~\r\n
) are the only characters following the opening triple-quote, then it's a multiline string with indentation:- The first line
~\n
is discarded. - The closing triple-quote can be either
"""
or~"""
(~
allows the string to end with"
without escaping). - Indentation is allowed but not required for empty lines.
- Indentation level is determined by the least number of leading spaces among the non-empty lines.
- If the closing triple-quote takes the whole line, it's allowed to be indented less than other lines,
but if it's indented more than other lines, the spaces are treated as part of the string. - Backslash is NOT a escape character.
- If a string has three consecutive quotes, there are two workarounds:
- Make use of string concatenation, and only escape the triple-quotes. e.g.
a = """~ line1 ~""" "line2\"\"\"\n" """~ line3 ~"""
- Use normal string with escape sequence.
For example:a = "line1\nline2\"\"\"\nline3\n"
- Make use of string concatenation, and only escape the triple-quotes. e.g.
- The first line
Some examples:
rule_engine {
ignore_sys_message = true
jq_function_default_timeout = 10s
rules {
a_WH_D {
actions = ["http:a_WH_D"]
description = ""
enable = true
metadata {created_at = 1707562385536}
name = ""
sql = """~
SELECT
*
FROM
"#",
"$events/message_delivered",
"$events/message_acked",
"$events/message_dropped",
"$events/client_connected",
"$events/client_disconnected",
"$events/client_connack",
"$events/client_check_authz_complete",
"$events/session_subscribed",
"$events/session_unsubscribed",
"$events/delivery_dropped"~"""
}
rule_rc0w {
actions = [
{
args {
mqtt_properties {}
payload = "${.}"
qos = 0
retain = false
topic = "republish-event/${clientid}"
user_properties = ""
}
function = republish
},
{function = console}
]
enable = true
metadata {created_at = 1707389712653}
name = ""
sql = """~
SELECT
*
FROM
"$events/client_connected",
"$events/client_disconnected"
~"""
}
rule_xlu4 {
actions = [
{function = console}
]
description = ""
enable = true
metadata {created_at = 1706611936022}
name = ""
sql = """~
SELECT
*
FROM
"t/#"
~"""
}
}
}
0.41.0
Added support for multiline string indentation.
Feature can be summarised as in README.md
- Quotes next to triple-quotes needs to be escaped, otherwise they are discarded.
Meaning"""a""""
is parsed asa
but nota"
, to crrectly expressa"
, it must be one of below:- Escape the last
"
:"""a\""""
; - Or add
~
around the string value:"""~a"~"""
(see below).
- Escape the last
- Multiline strings allow indentation (spaces, not tabs).
If~\n
(or~\r\n
) are the only characters following the opening triple-quote, then it's a multiline string with indentation:- The first line
~\n
is discarded; - The closing triple-quote can be either
"""
or~"""
(~
allows the string to end with"
without escaping). - Indentation is allowed but not required for empty lines;
- Indentation level is determined by the least number of leading spaces among the non-empty lines;
- If the closing triple-quote takes the whole line, it's allowed to be indented less than other lines,
but if it's indented more than other lines, the spaces are treated as part of the string. - Backslashes are treated as escape characters, i.e. should be escaped with another backslash; (NOTE: changed in 0.42.0)
- There is no need to escape quotes in multiline strings, but it's allowed. (NOTE: changed in 0.42.0)
- The first line
Some examples:
rule_engine {
ignore_sys_message = true
jq_function_default_timeout = 10s
rules {
a_WH_D {
actions = ["http:a_WH_D"]
description = ""
enable = true
metadata {created_at = 1707562385536}
name = ""
sql = """~
SELECT
*
FROM
"#",
"$events/message_delivered",
"$events/message_acked",
"$events/message_dropped",
"$events/client_connected",
"$events/client_disconnected",
"$events/client_connack",
"$events/client_check_authz_complete",
"$events/session_subscribed",
"$events/session_unsubscribed",
"$events/delivery_dropped"~"""
}
rule_rc0w {
actions = [
{
args {
mqtt_properties {}
payload = "${.}"
qos = 0
retain = false
topic = "republish-event/${clientid}"
user_properties = ""
}
function = republish
},
{function = console}
]
enable = true
metadata {created_at = 1707389712653}
name = ""
sql = """~
SELECT
*
FROM
"$events/client_connected",
"$events/client_disconnected"
~"""
}
rule_xlu4 {
actions = [
{function = console}
]
description = ""
enable = true
metadata {created_at = 1706611936022}
name = ""
sql = """~
SELECT
*
FROM
"t/#"
~"""
}
}
}
0.39.9
What's Changed
- fix: builtin type don't convert from_string when value is integer by @zhongwencool in #259
Full Changelog: 0.39.8...0.39.9
0.39.8
What's Changed
- fix(hocon_token): fix scan error message format by @zmstone in #257
- feat: transform atom to binary if serializable=true by @zhongwencool in #258
Full Changelog: 0.39.7...0.39.8
0.39.5
What's Changed
- test: add a test case to cover array of union default value fill by @zmstone in #251
- fix: map converter only works on map, but not each of its value by @zmstone in #252
- fix: merge struct when mix alias by @zhongwencool in #253
- fix: convert to different union type crash by @zhongwencool in #254
Full Changelog: 0.39.4...0.39.5
0.35.0
0.31.0
What's Changed
- chore: make scan invalid utf8 error more clear by @zhongwencool in #210
- Remove env meta from array by @zhongwencool in #211
Full Changelog: 0.30.0...0.31.0
0.28.3
What's Changed
- refactor: make a function more tracable by @zmstone in #206
- fix: improve schema cache speed by @zhongwencool in #207
Full Changelog: 0.28.2...0.28.3
0.28.1
What's Changed
- feat: allow early return when throw in validations/translations by @zhongwencool in #200
Full Changelog: 0.28.0...0.28.1
0.28.0
What's Changed
- feat: generate example.conf from schema by @zhongwencool in #199
Full Changelog: 0.27.5...0.28.0