avaje-config icon indicating copy to clipboard operation
avaje-config copied to clipboard

Add avaje-config-json

Open mechite opened this issue 1 year ago • 5 comments
trafficstars

An experiment, created a simple parser with jsonb dependency as a separate module.

Did this because I saw #94 was closed, and this seemed like the first simple thing that never got done, adding rudimentary JSON support like another one of the languages here seems quite simple?

If we want to do more advanced stuff, like destructure a more nested JSON structure into key/value with . to seperate the levels. for example:

{
    "postgresql": {
        "host": "127.0.0.1"
    }
}

to be destructured into "postgresql.host" = "127.0.0.1" in the Map<String, String>,

this pull request does not achieve that. It will only support a flat JSON structure. I didn't check what the YAML parser does.

Go ahead and make changes to this PR if you think it's a good idea, close it if not

mechite avatar Sep 03 '24 04:09 mechite

EDIT - Moved to #172 (this PR originally brought #172 in along with it. It has been separated out)

mechite avatar Sep 03 '24 17:09 mechite

I'm not totally sold on json as a config, @rbygrave what do you think?

SentryMan avatar Sep 04 '24 03:09 SentryMan

For myself, I'm personally extremely unlikely to use json for configuration of a Java application (where we have properties files which are so simple).

I'm happy to merge and include this if someone is going to say that they will actually use it? If no one has any immediate use case for this then I'm also happy for this PR to sit here for a bit and see what comments it gets.

rbygrave avatar Sep 08 '24 09:09 rbygrave

@SentryMan @rbygrave @Mechite

For me the challenge in config is not so much formats (parsing) but where the key values are coming from and if they have to be transformed. See #175

That is the source from where it comes from more often dictates what its format is anyway so I just don't find JSON config useful either.

agentgt avatar Sep 20 '24 14:09 agentgt

@agentgt Absolutely agreed. I think even for an extremely large set of configurations, migrating formats would be more than trivial, even with special types like datetime being used with formats that support it.

mechite avatar Sep 20 '24 16:09 mechite

closing until somebody actually needs it

SentryMan avatar Apr 02 '25 03:04 SentryMan

FWIW since I might steal @rbygrave simple YAML parser some day one could steal my JSON5 parser: https://github.com/jstachio/ezkv/tree/main/ezkv-json5

JSON5 is much nicer than regular JSON. It looks and feels similar to HCL (hashicorps config language) or typesafe config (HUCON). In fact I prefer JSON5 over YAML.

agentgt avatar Apr 02 '25 19:04 agentgt

@agentgt Highly agreed.

I personally actually dislike TOML syntax, but one thing that TOML got right (at the last time that I read their documentation several years ago), is that YAML is extremely convoluted with far too many ways to do the exact same thing.

It becomes unclear what the resultant data structure exposed to your environment is, when your language has so many different, badly documented ways to do the exact same thing. The YAML specification is larger than the XML and XML namespaces specification combined.

JSON5, on the other hand, very simple, well-designed standard.

mechite avatar Apr 03 '25 20:04 mechite