Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Can't read JSON configuration object from a view #346

Closed
bgoetzmann opened this issue Jun 14, 2017 · 2 comments
Closed

Can't read JSON configuration object from a view #346

bgoetzmann opened this issue Jun 14, 2017 · 2 comments

Comments

@bgoetzmann
Copy link

I a simple TornadoFX app I defined a configuration file, app.properties, with this content:

test={"greeting": "Hello"}

And in my App class I'm able to read the JSON object like this without problem:

init {
    val obj = config.jsonObject("test")
    println(obj?.string("greeting")) // displays Hello
}

Now, in my main View (in the init block), I can't access the JSON object with this code:

val obj = app.config.jsonObject("test")
println(obj?.string("greeting"))

I got null for obj!

What's seem strange is that the following code works (I use similar code from the extension function fun Properties.jsonObject(key: String) from Configurable inferface code):

val obj1 = app.config.getProperty("test").let {
    Json.createReader(StringReader(it)).readObject()
}
println(obj1.string("greeting")) // displays Hello

What's going on?

Thanks!

Bertrand

edvin pushed a commit that referenced this issue Jun 14, 2017
@edvin
Copy link
Owner

edvin commented Jun 14, 2017

Hi Bertrand,

This was actually due to a framework bug. I have committed a fix for it now. The extension function defined inside Component on Properties.jsonObject actually looked up the value in the View's config file instead of the app config file. Thanks for reporting this :)

You can work around it like you did until the next release, unless you want to run against a snapshot. I have built a snapshot and published it to the sonatype repo just in case :)

@edvin
Copy link
Owner

edvin commented Jun 15, 2017

This fix is in 1.7.7 which was just released :)

@edvin edvin closed this as completed Jun 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants