Last active
February 10, 2020 02:46
-
-
Save srkiNZ84/5e585551bfd32c70e3e544a83a1b1b25 to your computer and use it in GitHub Desktop.
Groovy test to check whether it does or does not interpert hash values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo: | |
bar: | |
baz: something | |
anotherfoo: | |
secondbar: otherthing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('org.yaml:snakeyaml') | |
import org.yaml.snakeyaml.Yaml | |
Yaml parser = new Yaml() | |
def example = parser.load(("/tmp/foobar.yaml" as File).text) | |
println(example) | |
def varKeyBaz = "baz" | |
def varKeyBarBaz = 'bar.baz' | |
println("Var key is ${varKeyBaz}") | |
println(example.foo.bar."${varKeyBaz}") // works | |
println(example.foo."${varKeyBarBaz}") // does not work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment