akka-js / shocon

Simple pure-scala Typesafe HOCON implementation using FastParse
Apache License 2.0
74 stars 21 forks source link

Use of shocon without Typesafe Config? #22

Closed darkfrog26 closed 6 years ago

darkfrog26 commented 7 years ago

Is there any way to use shocon to just parse a HOCON file and then convert it to JSON without the whole config loader baggage?

evacchi commented 7 years ago

Sure, look at the parser api

evacchi commented 7 years ago

Basically everything under the eu.unicredit package

darkfrog26 commented 6 years ago

Sorry for the late response to this, but the issue I'm facing now is that your facade (https://github.com/akka-js/shocon/tree/master/shared/src/main/scala/com/typesafe/config) is getting in the way for projects that actually use Typesafe Config (Akka for example). I'm getting:

java.lang.NoSuchMethodError: com.typesafe.config.ConfigFactory.load(Ljava/lang/ClassLoader;)Lcom/typesafe/config/Config;

Because it's not hitting Typesafe Config now, it's hitting the facade instead. Can this functionality be broken out into a different module to avoid this problem?

andreaTP commented 6 years ago

it makes sense to publish two separate modules(basic parser and typesafe config facade), PR are welcome or I will eventually do it at some point.

darkfrog26 commented 6 years ago

@andreaTP PR submitted. Let me know if I've missed something. It's a bit hacky as the SBT file could really use some cleanup, but that's a PR for another day. ;)

darkfrog26 commented 6 years ago

@andreaTP when can I expect a new release to Maven?

evbo commented 3 years ago

@evacchi I am looking at shocon.ConfigParser.parseString. Is this the right method to return JSON?

I understand a lot may have changed since 2018 when this issue was filed. Please let me know the new intended way to read a hocon file and output json. I am using scalajs to import the file like so:

@js.native
@JSImport("assets/app.conf", JSImport.Default)
object AppConfig extends js.Any

// this returns shocon.Config.Object... how do I get Json?
shocon.ConfigParser.parseString(AppConfig.asInstanceOf[String])