CodeGym
AI Academy
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme

Lessons

  • Reviews
  • About us
Start
Start learning
Start learning now
  • My Progress
  • Courses
  • University
  • Quest Map
  • Lessons
  • JsonElement as a JSON tree

    Kotlin SELF
    Level 49, Lesson 0
    We break down how to use JsonElement as a “JSON tree” in kotlinx.serialization: parse text via Json.parseToJsonElement(...), distinguish JsonObject/ JsonArray/ JsonPrimitive/ JsonNull, navigate nodes safely with when and as?, and also not confuse “the field is missing” with “the field exists, but is null”.
    Available
  • Safe data extraction from a JSON tree

    Kotlin SELF
    Level 49, Lesson 1
    We break down the practice of safe navigation through a JSON tree in kotlinx.serialization: how to work with JsonElement/ JsonObject without crashes, why JsonElement? keeps popping up everywhere, how “key is missing” differs from JsonNull, and how to assemble extraction into predictable helper functions ( getStringOrNull, getIntOrNull, getObjectOrNull, getArrayOrNull). Separately: safe conversions via toIntOrNull()/ toDoubleOrNull()/ toBooleanStrictOrNull() and common mistakes ( !!, toInt(), early defaults).
    Available
  • JSON Data Validation

    Kotlin SELF
    Level 49, Lesson 2
    We will go through a practical pipeline for processing incoming JSON in Kotlin: separating text parsing into JsonElement from structure and business-rule checks, designing the result contract via ValidationResult ( Ok/ Error) instead of Boolean, writing helper functions for safe field reading, and building an expense-import validator for a CLI (including fail-fast with the item index).
    Available
  • Building JSON manually — reports and non-standard structures

    Kotlin SELF
    Level 49, Lesson 3
    We break down how, in Kotlin, to manually assemble JSON reports via the JsonElement tree: compute aggregates separately, then wrap them with buildJsonObject/ buildJsonArray, use JsonPrimitive and JsonNull, distinguish “no field” vs “field = null”, and also combine manual assembly with Json.encodeToJsonElement and get nice output with prettyPrint.
    Available
  • JSON vs XML — practical criteria for choosing a format

    Kotlin SELF
    Level 49, Lesson 4
    We break down how to make a deliberate choice between JSON and XML: “data vs document”, primitive typing ( true, 123, "text", null), lists, attributes, ordering, and schemas/validation. Using Kotlin examples, we show why the JsonElement tree is convenient for unstable structures, why it’s worth separating parsing from business validation, and why generation is better done via buildJsonObject rather than by concatenating strings.
    Available
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym