Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one specify multi-line strings in Typesafe Config?

I have the following configuration file that I want to use from Scala applying this library:

P11 {
    yes="0.0"
    no="1.0"
}

P12 {
    yes="0.01"
    no="0.99"
}

P13 {
id = "123 567 \
T 0: \
If (f 23 <= 0.0)"
}

This is how I do it:

import com.typesafe.config.ConfigFactory

val configFileName = "/usr/develop/tests/config.conf"
val parsedConfigMCF = ConfigFactory.parseFile(new File(configFileName))
val confMCF = ConfigFactory.load(parsedConfigMCF)

Then I get the error:

Expecting a value but got wrong token: 'newline' (backslash followed by 'newline', this is not a valid escape sequence

It looks like it does not like \ (backslash), but I need to put several lines for id in P13.

like image 620
duckertito Avatar asked Nov 11 '16 16:11

duckertito


1 Answers

From official documentation of Typesafe Config:

multi-line strings with triple quotes as in Python or Scala

so:

P13 {
  id = """123 567
  T 0:
  If (f 23 <= 0.0)"""
}
like image 173
Andrey Avatar answered Sep 25 '22 00:09

Andrey