JsonFF4kConfigurationParser

JSON-based implementation of FF4kConfigurationParser for FF4kConfiguration.

This parser uses kotlinx.serialization to handle JSON serialization and deserialization of FF4k configurations, with full support for polymorphic property types.

Features

  • Pretty-printed output: Exported JSON is formatted for readability.

  • Lenient parsing: Unknown keys in JSON are ignored, enabling forward compatibility.

  • Polymorphic properties: All property types (int, string, boolean, etc.) are correctly serialized and deserialized using type discriminators.

Usage

val parser = JsonFF4kConfigurationParser()

// Load from resources (e.g., bundled config)
val config = parser.parseConfigurationResource("ff4k_config.json")

// Load from filesystem
val fileConfig = parser.parseConfigurationFile("/path/to/config.json")

// Export configuration to JSON string
val jsonString = parser.export(config)

Parameters

json

Custom Json instance for serialization. Defaults to a pre-configured instance with pretty printing, lenient parsing, and FF4k serializers module.

See also

Constructors

Link copied to clipboard
constructor(json: Json = DEFAULT_PARSER)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend override fun export(configuration: FF4kConfiguration): String

Exports a configuration object to its serialized string representation.

Link copied to clipboard
open suspend override fun parseConfigurationFile(file: String): FF4kConfiguration

Parses a configuration from a file on the filesystem.

Link copied to clipboard
open suspend override fun parseConfigurationResource(file: String): FF4kConfiguration

Parses a configuration from a resource file bundled with the application.