Airframe

Airframe

  • Docs
  • Blog
  • Release Notes
  • GitHub

›Utilities

Resources

  • Overview
  • Articles
  • Release Notes
  • Logos

Framework

  • airframe-di: Dependency Injection
  • Airframe RPC
  • airframe-http: Creating REST Service
  • airframe-rx: ReactiveX interface
  • AirSpec: Testing Framework

Core Modules

  • airframe-codec: Schema-On-Read Object Serializer
  • airframe-config: Application Config Flow
  • airframe-control: Retry/Rate Control
  • airframe-log: Application Logger
  • airframe-metrics: Human-Friendly Measures for Time and Data Size
  • airframe-surface: Object Shape Inspector

Utilities

  • airframe-benchmark: JMH Benchmark
  • airframe-canvas: Off-Heap Memory Manager
  • airframe-fluentd: Fluentd Logger
  • airframe-http-recorder: Web Request/Response Recorder
  • airframe-jdbc: JDBC Connection Pool
  • airframe-jmx: JMX Application Monitor
  • airframe-json: Pure-Scala JSON Parser
  • airframe-launcher: Command-Line Program Launcher
  • airframe-msgpack: Pure-Scala MessagePack Parser
  • airframe-parquet: Parquet Columnar File Reader and Writer
  • airframe-sql: SQL Parser
  • airframe-ulid: ULID Generator

airframe-json: Pure-Scala JSON Parser

airframe-json is a pure-Scala json parser.

Usage

Maven Central

libraryDependencies += "org.wvlet.airframe" %% "airframe-json" % "(version)"

Parsing JSON

import wvlet.airframe.json.JSON

// Returns a JSON value object of the input JSON string 
val jsonValue = JSON.parse("""{"id":1, "name":"leo"}""")

Mapping JSON into object

With airframe-codec, it supports JSON to object mapping.

Add airframe-codec to your dependency:

libraryDependencies += "org.wvlet.airframe" %% "airframe-codec" % "(version)"

MessageCodec will create a JSON encoder and decorder for your objects:

import wvlet.airframe.codec.MessageCodec

case class Person(id:Int, name:String)

val p = Person(1, "leo")

val codec = MessageCodec.of[Person]
// Convert the object to JSON representation
val json = codec.toJson(p) // {"id":1, "name":"leo"}

// Read JSON as case class 
codec.unpackJson(json) // Some(Person(1, "leo"))

← airframe-jmx: JMX Application Monitorairframe-launcher: Command-Line Program Launcher →
  • Usage
    • Parsing JSON
    • Mapping JSON into object
Airframe
Docs
Documentation
Community
Gitter Chat
More
GitHubStar
airframe logo
Copyright © 2024 wvlet.org