{"id":22750097,"url":"https://github.com/pwall567/kjson-spring","last_synced_at":"2026-05-02T20:38:06.538Z","repository":{"id":40599308,"uuid":"507712205","full_name":"pwall567/kjson-spring","owner":"pwall567","description":"Spring JSON message converter for kjson","archived":false,"fork":false,"pushed_at":"2023-10-15T10:20:55.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-21T08:56:24.995Z","etag":null,"topics":["json","kotlin","spring"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pwall567.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2022-06-27T00:03:54.000Z","updated_at":"2023-07-09T17:33:54.000Z","dependencies_parsed_at":"2023-10-16T03:13:25.252Z","dependency_job_id":null,"html_url":"https://github.com/pwall567/kjson-spring","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"5e6795f21899f624713ab1627b012fe9acc7a6f5"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/pwall567/kjson-spring","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Fkjson-spring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Fkjson-spring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Fkjson-spring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Fkjson-spring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwall567","download_url":"https://codeload.github.com/pwall567/kjson-spring/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Fkjson-spring/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32549384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T19:18:06.202Z","status":"ssl_error","status_checked_at":"2026-05-02T19:16:21.335Z","response_time":132,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["json","kotlin","spring"],"created_at":"2024-12-11T04:12:22.285Z","updated_at":"2026-05-02T20:38:01.528Z","avatar_url":"https://github.com/pwall567.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kjson-spring\n\n[![Build Status](https://travis-ci.com/pwall567/kjson-spring.svg?branch=main)](https://travis-ci.com/github/pwall567/kjson-spring)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Kotlin](https://img.shields.io/static/v1?label=Kotlin\u0026message=v1.8.22\u0026color=7f52ff\u0026logo=kotlin\u0026logoColor=7f52ff)](https://github.com/JetBrains/kotlin/releases/tag/v1.8.22)\n[![Maven Central](https://img.shields.io/maven-central/v/io.kjson/kjson-spring?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.kjson%22%20AND%20a:%22kjson-spring%22)\n\nSpring Boot 2 JSON message converter for [`kjson`](https://github.com/pwall567/kjson).\n\n## Background\n\nMany users of the [`kjson`](https://github.com/pwall567/kjson) library will seek to use the library in conjunction with\nthe [Spring Framework](https://spring.io/projects/spring-framework).\nThe `kjson-spring` library provides a JSON converter class that will use `kjson` as the serialization / deserialization\nmechanism.\n\nThis version is for Spring Boot 2.x and Spring 5.x; for Spring Boot 3.x and Spring 6.x see\n[`kjson-spring3`](https://github.com/pwall567/kjson-spring3).\n\n## Quick Start\n\nTo direct a Spring Boot application to use `kjson` for serialization and deserialization of HTTP(S) requests and\nresponses, simply include the `kjson-spring` library in the build, and then ensure that the `io.kjson.spring` package is\nincluded in the Spring component scan:\n```kotlin\n@ComponentScan(\"io.kjson.spring\")\n```\nor:\n```kotlin\n@ComponentScan(basePackageClasses = [JSONSpring::class])\n```\nor, when using Spring XML configuration:\n```xml\n    \u003ccontext:component-scan base-package=\"io.kjson.spring\"/\u003e\n```\nNote that the default Spring behaviour is to scan the package in which the `@ComponentScan`\n(or `@SpringBootApplication`) occurs.\nWhen one or more packages or classes are specified on a `@ComponentScan`, only the specified package(s) will be scanned;\nto retain the default behaviour, the current package must be also specified, along with `io.kjson.spring`.\n\n## Configuration\n\nThe `kjson` serialization and deserialization functions all take an optional\n[`JSONConfig`](https://github.com/pwall567/kjson/blob/main/USERGUIDE.md#configuration) object.\nThe `JSONConfig` to be used by the `kjson-spring` library may be provided in the usual Spring manner:\n```kotlin\n@Configuration\nopen class SpringAppConfig {\n\n    @Bean open fun jsonConfig(): JSONConfig {\n        return JSONConfig {\n            allowExtra = true\n        }\n    }\n\n}\n```\nThis example shows just the `allowExtra` option being set; any of the configuration options, including custom\nserialization and deserialization, may be used.\nIf no `JSONConfig` is provided, the `JSONConfig.defaultConfig` will be used.\n\n## Client REST Calls\n\nClient REST calls using the `RestTemplate` class can also make use of the `kjson` serialization and deserialization\nfunctions.\nWhen the `RestTemplate` is obtained from the default `RestTemplateBuilder`, it will be configured with all of the\n`HttpMessageConverter` instances that it locates in the component scan \u0026ndash; that will include the `kjson`\nconverter if the component scan is configured as described above.\n\nThe following line will get the default `RestTemplateBuilder`:\n```kotlin\n    @Autowired lateinit var restTemplateBuilder: RestTemplateBuilder\n```\nAnd then, the following will get a `RestTemplate` with the converters configured in the `RestTemplateBuilder`:\n```kotlin\n        val restTemplate = restTemplateBuilder.build()\n```\n\nAlternatively, the `RestTemplate` may be constructed with the converter specified explicitly:\n```kotlin\n    @Autowired lateinit var jsonSpring: JSONSpring\n```\nand:\n```kotlin\n        val restTemplate = RestTemplate(listOf(jsonSpring))\n```\n\n## Logging\n\n`kjson-spring` can be configured to log all messages processed by the JSON converter, input and output.\nTo make use of this functionality, the `jsonLogFactory` must be configured, as follows:\n```kotlin\n    @Bean open fun jsonLogFactory(): LoggerFactory\u003c*\u003e = DynamicLoggerFactory(Level.DEBUG)\n```\n\nThe `LoggerFactory` in this case is from the [log-front-api](https://github.com/pwall567/log-front-api) library;\nthis is a logging fa\u0026ccedil;ade library which will delegate to any of a number of implementations.\nThe example above uses the `DynamicLoggerFactory` class from the [log-front](https://github.com/pwall567/log-front)\nlibrary, and this implementation uses `slf4j` if those classes are present (they generally are in a Spring application),\nor the Java Logging framework if a configuration file for that system is specified, or if no other logging mechanism is\navailable, logs to the standard output.\n\nFor the majority of users who do not wish to learn another logging library, the example above will meet most\nrequirements (the `Level.Debug` in the example is the default level to be used by `Logger` objects created by this\n`LoggerFactory`).\n\nThe name of the `Logger` may also be specified:\n```kotlin\n    @Bean open fun jsonLogName(): String = \"JSON Logging\"\n```\nThe default name is the name of the class instantiating the `Logger`, which in this case is\n`io.kjson.spring.JSONSpring`.\n\n## Log Eliding\n\nWhen logging JSON content, it is often important to ensure that Personally Identifiable Information (PII) is not\nincluded in the logged data.\nThe logging functionality of `kjson-spring` allows the specification of an optional \"exclude\" set of property names.\nThe values of properties with these names will be replaced by `****` in the logs, wherever they appear in a JSON\nstructure.\n```kotlin\n    @Bean open fun jsonLogExclude(): Collection\u003cString\u003e = setOf(\"creditCardNumber\", \"licenceNumber\")\n```\n\n## Dependency Specification\n\nThe latest version of the library is 7.1 (the version number of this library matches the version of `kjson` with which\nit was built), and it may be obtained from the Maven Central repository.\n\nThis version was built using version 5.3.30 of Spring, and version 2.7.16 of Spring Boot.\n\n### Maven\n```xml\n    \u003cdependency\u003e\n      \u003cgroupId\u003eio.kjson\u003c/groupId\u003e\n      \u003cartifactId\u003ekjson-spring\u003c/artifactId\u003e\n      \u003cversion\u003e7.1\u003c/version\u003e\n    \u003c/dependency\u003e\n```\n### Gradle\n```groovy\n    implementation 'io.kjson:kjson-spring:7.1'\n```\n### Gradle (kts)\n```kotlin\n    implementation(\"io.kjson:kjson-spring:7.1\")\n```\n\nPeter Wall\n\n2023-10-15\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwall567%2Fkjson-spring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwall567%2Fkjson-spring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwall567%2Fkjson-spring/lists"}