I have file in HOCON format where a very long string is assigned to a key. The string contains single quotes (and other "illegal" characters), and hence I need to enclose the value in double quotes. Something like this:
key="extremely long string with 'illegal' characters :;/. bla bla ..."
For readability, I would like to split this up into multiple lines. I simple have not found a way to do this. If the string weren't enclosed by double quotes, I could use \
to split lines. And if I didn't care about adding newlines, I could use """
. But I do care about these things.
I have studied the informal HOCON specs but have still not found a solution.
(Since HOCON resembles JSON (which I don't know anything about), I have tagged this question with "JSON" as well.)
you could use hocon self-refs - for example, hocon section:
simple.database {
host = "db-server"
port = "5432"
name = "postgres"
user = "postgres"
pass = "postgres"
connection {
driver = "org.postgresql.Driver"
url = "jdbc:postgresql://"${simple.database.host}":"${simple.database.port}
url = ${simple.database.connection.url}"/"${simple.database.name}
url = ${simple.database.connection.url}"?ssl="true
url = ${simple.database.connection.url}"&user="${simple.database.user}
url = ${simple.database.connection.url}"&password="${simple.database.pass}
}
}
produces after resolution:
url = "jdbc:postgresql://db-server:5432/postgres?ssl=true&user=postgres&password=postgres"