scalacirce-optics

Circe-Optics how to specify a path with dash


I am trying to access a field in json with circe-optics. Issue is the field contains a dash:

root.TAB-NR.string

While if i write

root.TAB_NR.string it works, but the field does not exist.

Any idea how i can handle this case ?


Solution

  • If you need to use special characters in Scala identifiers that would otherwise be illegal, you can use backticks to quote them.

    val `my funky value` = root.`TAB-NR`.string