RepositoryKotlinCNTrung Quốc
kanyun-inc

kanyun-inc/Kudos

Powerful utilities for deserializing Kotlin classes with Gson, Jackson and Android JsonReader.

130sao
7fork
0issue
0lượt xem

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: gson

#1 Repository Của Tháng

1
TINIX TRENDING·Chủ đề: jsonreader

#1 Repository Của Tháng

1
TINIX TRENDING·Chủ đề: kcp

#1 Repository Của Tháng

🔧 Kudos: An toàn null + giá trị mặc định cho Gson, Jackson và JsonReader

Plugin biên dịch Kotlin cung cấp hỗ trợ null safety và default values cho các framework deserialize phổ biến.

Kudos (viết tắt của Kotlin Utilities for Deserializing Objects) là một plugin biên dịch giúp các lớp Kotlin được deserialize an toàn hơn với Gson, Jackson và Android JsonReader. Thông thường, các framework này bỏ qua giá trị mặc định của tham số hàm tạo và gây lỗi null do thiếu no-arg constructor. Kudos giải quyết vấn đề này bằng cách sinh constructor phù hợp và điều chỉnh quá trình khởi tạo.

✨ Điểm nổi bật

  • No-arg constructor an toàn: Tự động sinh constructor rỗng cho lớp có annotation @PoKo.
  • Hỗ trợ invokeInitializers: Bật khởi tạo đúng giá trị mặc định trong constructor.
  • Null safety toàn diện: Tránh gán null cho kiểu non-nullable khi thiếu trường JSON.
  • Default values được giữ nguyên: Các tham số có giá trị mặc định sẽ được áp dụng đúng khi thiếu trường.
  • Tích hợp JsonReader hiệu năng cao: Cung cấp DSL đơn giản để dùng JsonReader mà vẫn an toàn kiểu.
  • Hỗ trợ đa framework: Tương thích Gson, Jackson và Android JsonReader.

💡 Vì sao đáng chú ý

Thay vì chuyển sang Moshi hay kotlinx.serialization — tốn thời gian migration và thiếp thu cú pháp mới — Kudos giữ nguyên cách dùng quen của Gson/Jackson nhưng thêm lớp bảo vệ null safety và default values. Đặc biệt, với JsonReader, Kudos sinh mã tự động qua compiler plugin, giúp tránh viết thủ công vòng lặp parse JSON mà vẫn giữ hiệu năng cao của JsonReader.


#Kotlin #Gson #Jackson #JsonReader #CompilerPlugin #NullSafety #TiniX

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryKotlin
JetBrains/kotlin

The Kotlin Programming Language.

53.5k
Oct 23, 2026
RepositoryKotlin
wuseal/JsonToKotlinClass

🚀 Plugin for Android Studio And IntelliJ Idea to generate Kotlin data class code from JSON text ( Json to Kotlin )

3.2k
Jun 3, 2025
RepositoryJava
apple/pkl

A configuration as code language with rich validation and tooling.

11.6k
Oct 27, 2026
RepositoryJava
joelittlejohn/jsonschema2pojo

Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc

6.4k
May 2, 2026
RepositoryJava
immutables/immutables

Java annotation processor to create immutable objects and builders, for records too. Sweep boilerplate code under the rug!

3.6k
Oct 11, 2026
RepositoryJava
mizosoft/methanol

⚗️ Lightweight HTTP extensions for Java & Kotlin

299
Oct 5, 2026
Repository
getify/You-Dont-Know-JS

A book series (2 published editions) on the JS language.

184.8k
Feb 15, 2026
RepositoryRust
rust-lang/rust

Empowering everyone to build reliable and efficient software.

120.9k
Oct 29, 2026
RepositoryTypeScript
freeCodeCamp/freeCodeCamp

freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.

458.2k
Oct 29, 2026