Json Serialization/Deserialization Implicits

Data Client Base Library uses common Scala case classes to serialize/deserialize json objects. To support this feature you need to import a lot of implicits. We grouped up all of them to the union file com.here.platform.data.client.base.generated.codecs.JsonSupport. Now, to provide all implicits which are needed to serialize or deserialize case classes for library requests, all you need is just to import everything from this file like this:

Import JsonSupport
import com.here.platform.data.client.base.generated.codecs.JsonSupport._

This is how a simple application with json serialization/deserialization should look like if you would like to use Scala's global execution context. Of course, you can define your own execution context if needed. Also, you can define your own encoders/decoders, but we highly suggest using the ones that come with the library as in this example:

Simple application
import com.here.platform.data.client.base.generated.codecs.JsonSupport._
import com.here.platform.data.client.base.generated.scaladsl.api.metadata.MetadataApi
import com.here.platform.data.client.base.generated.scaladsl.model.metadata.{CatalogVersion, Dependencies}
import com.here.platform.data.client.base.scaladsl.BaseClient

import scala.concurrent.ExecutionContext.Implicits.global

object Test extends App {
  val baseClient = BaseClient()
  val metadataApi = baseClient.of[MetadataApi]

  val catalogHrn1 = ???
  val catalogHrn2 = ???

  val request = Dependencies(Some(Seq(CatalogVersion(catalogHrn1, 1L))))
  val response = metadataApi.compatibleVersions(catalogHrn2, request)

  println(response.toEntity())
}

results matching ""

    No results matching ""