jsonclient

Simple Json Http Client

License

License

Categories

Categories

CLI User Interface JSON Data
GroupId

GroupId

org.mellowtech
ArtifactId

ArtifactId

jsonclient_2.12
Last Version

Last Version

0.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

jsonclient
Simple Json Http Client
Project URL

Project URL

https://github.com/msvens/jsonclient
Project Organization

Project Organization

Mellowtech
Source Code Management

Source Code Management

https://github.com/msvens/jsonclient.git

Download jsonclient_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/org.mellowtech/jsonclient_2.12/ -->
<dependency>
    <groupId>org.mellowtech</groupId>
    <artifactId>jsonclient_2.12</artifactId>
    <version>0.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.mellowtech/jsonclient_2.12/
implementation 'org.mellowtech:jsonclient_2.12:0.5.0'
// https://jarcasting.com/artifacts/org.mellowtech/jsonclient_2.12/
implementation ("org.mellowtech:jsonclient_2.12:0.5.0")
'org.mellowtech:jsonclient_2.12:jar:0.5.0'
<dependency org="org.mellowtech" name="jsonclient_2.12" rev="0.5.0">
  <artifact name="jsonclient_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.mellowtech', module='jsonclient_2.12', version='0.5.0')
)
libraryDependencies += "org.mellowtech" % "jsonclient_2.12" % "0.5.0"
[org.mellowtech/jsonclient_2.12 "0.5.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.8
com.typesafe.akka : akka-http_2.12 jar 10.1.8
com.typesafe.akka : akka-stream_2.12 jar 2.5.23
de.heikoseeberger : akka-http-jsoniter-scala_2.12 jar 1.26.0

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.scalatest : scalatest_2.12 jar 3.0.5
org.pegdown : pegdown jar 1.4.2

Project Modules

There are no modules declared in this project.

Jsonclient

Build Status Maven Central

Overview

Dead simple Scala wrapper for Akka Http Client API that simplifies interacting with JSON Based Http APIs. It is optimized for json usage and will automatically convert responses and request to and from json. It uses jsoniter for this. With minimal bolierplate you should be up and running in minutes

Observe: Previous versions < 0.5.0) used AsyncHttpClient or Java 11 HttpClient and Json4s. Version 0.5.0+ is based on AkkaHttp and Jsoniter

2 Minute Usage Guide

import org.mellowtech.jsonclient.{JsonClient,JsonResponse}
import com.github.plokhotnyuk.jsoniter_scala.core._
import com.github.plokhotnyuk.jsoniter_scala.macros._
import scala.concurrent.Await
import scala.concurrent.duration._

case class ServerResponse(key: String, value: String)

object Test {
  import scala.concurrent.ExecutionContext.Implicits.global
  
  implicit val jsonCodec = JsonCodecMaker.make[ServerResponse](CodecMakerConfig())
  
   val jc = JsonClient()
   
   val resp = jc.get[ServerResponse]("http://pathToServiceApi")
   var res: JsonResponse[ServerResponse] = Await.result(resp, 4 seconds)
   println(res.body)
   
   jc.close
  
}

Todo

  • Better support for non json client requests
  • Proper testing
  • Simpler configuration (scala.config)
  • Chunked responses

Version History

  • 0.5.1 - Added example CLI and more documentation
  • 0.5.0 - Using Akka Http Client as backend
  • 0.4.0 - First version using Javas new HttpClient Api
  • 0.3.0 - First production release. Scala 2.12 and testing
  • 0.1.0-SNAPSHOT - initial snapshot release

Using JsonClient

Using JsonClientRequest

Using The Example CLI

Two Minute Intro to Jsoniter

JsonClient uses Jsoniter as its Json Parser backend. It has been chosen for its

  • ease of use
  • speed
  • out of the box handling of java.time

Versions

Version
0.5.0
0.4.0
0.3.1