{"id":13775107,"url":"https://github.com/dzikoysk/cdn","last_synced_at":"2025-05-09T01:45:35.551Z","repository":{"id":38009514,"uuid":"258192658","full_name":"dzikoysk/cdn","owner":"dzikoysk","description":"Simple and fast property-based configuration library for JVM apps, similar to JSON5 standard, also with JSON \u0026 YAML-like targets 🧾","archived":false,"fork":false,"pushed_at":"2025-04-19T14:25:52.000Z","size":628,"stargazers_count":62,"open_issues_count":6,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T18:10:33.612Z","etag":null,"topics":["cdn","configs","hacktoberfest","hjson","java","json5","panda-lang"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dzikoysk.png","metadata":{"files":{"readme":".github/README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"dzikoysk","custom":"https://panda-lang.org/support"}},"created_at":"2020-04-23T12:18:16.000Z","updated_at":"2025-04-19T14:20:58.000Z","dependencies_parsed_at":"2024-06-20T10:14:48.070Z","dependency_job_id":"d4720ff0-f1e4-42c9-b5f8-ba03faaff0b8","html_url":"https://github.com/dzikoysk/cdn","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzikoysk%2Fcdn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzikoysk%2Fcdn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzikoysk%2Fcdn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzikoysk%2Fcdn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dzikoysk","download_url":"https://codeload.github.com/dzikoysk/cdn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253176443,"owners_count":21866142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdn","configs","hacktoberfest","hjson","java","json5","panda-lang"],"created_at":"2024-08-03T17:01:34.022Z","updated_at":"2025-05-09T01:45:35.539Z","avatar_url":"https://github.com/dzikoysk.png","language":"Java","funding_links":["https://github.com/sponsors/dzikoysk","https://panda-lang.org/support"],"categories":["Configuration"],"sub_categories":[],"readme":"# CDN ![CDN CI](https://github.com/dzikoysk/cdn/workflows/CDN%20CI/badge.svg) [![Reposilite](https://maven.reposilite.com/api/badge/latest/releases/net/dzikoysk/cdn?color=40cc11\u0026name=Latest%20release\u0026prefix=v)](https://maven.reposilite.com/#/releases/net/dzikoysk/cdn) ![Maven Central](https://img.shields.io/maven-central/v/net.dzikoysk/cdn) [![codecov](https://codecov.io/gh/dzikoysk/cdn/branch/master/graph/badge.svg?token=374BLLP5OI)](https://codecov.io/gh/dzikoysk/cdn) [![CodeFactor](https://www.codefactor.io/repository/github/dzikoysk/cdn/badge)](https://www.codefactor.io/repository/github/dzikoysk/cdn)\nSimple and fast configuration library for JVM based apps, powered by CDN *(Configuration Data Notation)* format, based on enhanced JSON for Humans standard. Handles [CDN](https://github.com/dzikoysk/cdn), [JSON](https://www.json.org) and [YAML](https://yaml.org)-like configurations with built-in support for comments and automatic scheme updates.\n\n## Overview\n- [x] Supports Java, Kotlin _(dedicated extension)_ and Groovy\n- [x] Automatically updates configuration structure and migrates user's values\n- [x] Lightweight ~ 70kB\n- [x] Respects properties order and comment entries\n- [x] Bidirectional parse and render of CDN sources\n- [x] Serialization and deserialization of Java entities \n- [x] Indentation based configuration _(YAML-like)_\n- [x] Compatibility with JSON format\n- [x] Null-safe querying API\n\n### Table of Contents\n* [Installation](#installation)\n    * [Maven artifact](#gradle)\n    * [Manual](#manual)\n* [Using the Library](#using-the-library)\n    * [TL;DR](#tldr)\n    * [Load configuration](#load-configuration) \n    * [Update properties](#update-properties) \n    * [Save configuration](#save-configuration) \n    * [Supported formats](#supported-formats)\n\n### Installation\n\n#### Gradle\n\n```groovy\nrepositories {\n    maven { url 'https://repo.panda-lang.org/releases' }\n}\n\ndependencies {\n    // Default\n    implementation 'net.dzikoysk:cdn:1.14.8'\n    // Kotlin wrapper\n    implementation 'net.dzikoysk:cdn-kt:1.14.8'\n}\n```\n\n#### Manual\n\nYou can find all available versions in the repository:\n\n* [Repository - Artifact net.dzikoysk:cdn](https://repo.panda-lang.org/#/releases/net/dzikoysk/cdn)\n\n### Using the library\n\n#### TLDR\nA brief summary of how to use the library.\n\n```java\npublic final class AwesomeConfig {\n\n    @Description(\"# Comment\")\n    public String property = \"default value\";\n\n}\n```\n\nHandling:\n\n```java\nCdn cdn = CdnFactory.createStandard();\nFile configurationFile = new File(\"./config.cdn\");\n\n// Load configuration\nAwesomeConfig configuration = cdn.load(Source.of(configurationFile), AwesomeConfig.class).orThrow(identity());\n\n// Modify configuration\nconfiguration.property = \"modified value\";\n\n// Save configuration\ncdn.render(configuration).orThrow(identity());\n```\n\nTo explore all features, take a look at other chapters.\n\n#### Load configuration\n\nBy default, CDN is meant to use class-based configuration.\nIt means that configurations are accessed through the standard Java instance.\nLet's say we'd like to maintain this configuration:\n\n```hocon\nhostname: 'localhost'\n```\n\nAt first, every configuration is loaded into the `Configuration` object.\n\n```java\nConfiguration configuration = cdn.load(\"hostname: localhost\")\nString hostname = configuration.getString(\"hostname\", \"default value, if the requested one was not found\")\n```\n\nTo avoid such a cringe configuration handling, we can just map this configuration into the Java object.\nLet's declare the scheme:\n\n```java\npublic final class Config {\n    \n    public String hostname = \"default value\";\n    \n}\n```\n\nThe last thing to do is to provide this class during the load process:\n\n```java\nConfig config = cdn.load(\"hostname: localhost\", Config.class)\nconfig.hostname // returns 'localhost'\n```\n\n#### Update properties\n\nConfigurations can be updated in both variants. \nAs you can see in the previous chapter, we've declared hostname field as non-final.\nIt means we can just update it's value and CDN will update this field during next render.\n\n```java\nconfig.hostname = \"new value\";\n```\n\nFor configuration without scheme, we can use `setString` method:\n\n```java\nconfiguration.setString(\"hostname\", \"new value\");\n```\n\n#### Save configuration\n\nCDN can render configuration elements and entities using `render` methods.\nThe output depends on the installed format. \n\n#### Supported formats\nVarious formats ae supported through the `Feature` api. \nAvailable format features:\n\n* DefaultFeature (CDN)\n* JsonFeature\n* YamlFeature\n\nOutput comparison:\n \n\u003ctable\u003e\n \u003ctr\u003e\n  \u003cth\u003eStandard\u003c/th\u003e\n  \u003cth\u003eJSON feature\u003c/th\u003e\n  \u003cth\u003eYAML-like feature\u003c/th\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003e\n   \u003cpre lang=\"javascript\"\u003e\n# entry comment\nkey: value\n# section description\nsection {\n  list [\n    1st element\n    2nd element\n  ]\n}\n   \u003c/pre\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   \u003cpre lang=\"javascript\"\u003e\n\"key\": \"value\",\n\"section\": {\n \"list\": [\n  \"1st element\",\n  \"2nd element\"\n ]\n}\n   \u003c/pre\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   \u003cpre lang=\"yaml\"\u003e\n# entry comment\nkey: value \u003cbr\u003e\n# section description\nsection:\n  list:\n    - 1st element\n    - 2nd element\n   \u003c/pre\u003e\n  \u003c/td\u003e\n \u003c/tr\u003e\n\u003c/table\u003e\n\n#### Who's using\n* [Panda](https://github.com/panda-lang/panda)\n* [Reposilite](https://github.com/dzikoysk/reposilite)\n* [FunnyGuilds](https://github.com/FunnyGuilds/FunnyGuilds)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzikoysk%2Fcdn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdzikoysk%2Fcdn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzikoysk%2Fcdn/lists"}