JSON functionality for ktor HTTP clients

This library provides ktor client interface integration for the json-kotlin library.

License

License

Categories

Categories

Net CLI User Interface JSON Data
GroupId

GroupId

net.pwall.json
ArtifactId

ArtifactId

json-ktor-client
Last Version

Last Version

0.7
Release Date

Release Date

Type

Type

jar
Description

Description

JSON functionality for ktor HTTP clients
This library provides ktor client interface integration for the json-kotlin library.
Project URL

Project URL

https://github.com/pwall567/json-ktor-client
Source Code Management

Source Code Management

https://github.com/pwall567/json-ktor-client.git

Download json-ktor-client

How to add to project

<!-- https://jarcasting.com/artifacts/net.pwall.json/json-ktor-client/ -->
<dependency>
    <groupId>net.pwall.json</groupId>
    <artifactId>json-ktor-client</artifactId>
    <version>0.7</version>
</dependency>
// https://jarcasting.com/artifacts/net.pwall.json/json-ktor-client/
implementation 'net.pwall.json:json-ktor-client:0.7'
// https://jarcasting.com/artifacts/net.pwall.json/json-ktor-client/
implementation ("net.pwall.json:json-ktor-client:0.7")
'net.pwall.json:json-ktor-client:jar:0.7'
<dependency org="net.pwall.json" name="json-ktor-client" rev="0.7">
  <artifact name="json-ktor-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.pwall.json', module='json-ktor-client', version='0.7')
)
libraryDependencies += "net.pwall.json" % "json-ktor-client" % "0.7"
[net.pwall.json/json-ktor-client "0.7"]

Dependencies

compile (11)

Group / Artifact Type Version
net.pwall.json : json-ktor jar 1.3
net.pwall.json : json-kotlin jar 4.2
net.pwall.json : jsonutil jar 5.0
net.pwall.json : json-stream jar 0.8
net.pwall.util : pipelines jar 0.9
net.pwall.util : co-pipelines jar 0.6
net.pwall.json : json-co-stream jar 0.5
io.ktor : ktor-server-core jar 1.4.0
io.ktor : ktor-client-json-jvm jar 1.4.0
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.4.0
org.jetbrains.kotlin : kotlin-reflect jar 1.4.0

test (3)

Group / Artifact Type Version
io.ktor : ktor-client-mock jar 1.4.0
io.ktor : ktor-server-test-host jar 1.4.0
net.pwall.json : json-kotlin-test-classes jar 1.6

Project Modules

There are no modules declared in this project.

json-ktor-client

Build Status License: MIT Kotlin Maven Central

JSON functionality for ktor HTTP clients

This library provides ktor client interface integration for the json-kotlin library.

Quick Start

In the HttpClient engine specification, use:

    val client = HttpClient(HttpClientEngine) {
        Json {
            jsonKtorClient {}
        }
    }

Customizations (e.g custom serialization or deserialization) may be specified within the lambda supplied to the jsonKtorClient function:

    val client = HttpClient(HttpClientEngine) {
        Json {
            jsonKtorClient {
                fromJSON { json ->
                    require(json is JSONObject) { "Must be JSONObject" }
                    Example(json.getString("custom1"), json.getInt("custom2"))
                }
            }
        }
    }

For more details see the json-kotlin library.

Streaming Input

From version 0.2 onwards, this library uses the json-streaming library for on-the-fly JSON parsing. This means that the input data is parsed into an internal form as it is being read, and avoids the need to allocate memory for the entire JSON text.

Streaming Output

From version 0.5, the library will (optionally) stream output using a non-blocking output library (json-kotlin-nonblocking).

More documentation will be available shortly; in the meantime the unit test classes contain examples.

Dependency Specification

The latest version of the library is 0.7, and it may be obtained from the Maven Central repository.

Maven

    <dependency>
      <groupId>net.pwall.json</groupId>
      <artifactId>json-ktor-client</artifactId>
      <version>0.7</version>
    </dependency>

Gradle

    implementation 'net.pwall.json:json-ktor-client:0.7'

Gradle (kts)

    implementation("net.pwall.json:json-ktor-client:0.7")

Peter Wall

2021-04-25

Versions

Version
0.7
0.6
0.5.1
0.5
0.4
0.3.1
0.3
0.2
0.1