2

I have the table with json data type in Postgresql and i must choice the eligible mapping of this field in Scala code for case class field (i don't use slick where i can directly set something like sql.json). I consider the next variants:

  1. java.lang.Object with following validation.
  2. play.libs.Json or io.circe.Json

But i can't choice one of them and I don't other possible candidate for this place.

UPD For interacting with DB i use quill

pacman
  • 797
  • 10
  • 28
  • 2
    So... what do you use for interacting with your database ? The answer will heavily depend on that. – sarveshseri Apr 21 '17 at 07:14
  • @Sarvesh Kumar Singh i use quill for interacting with DB; – pacman Apr 21 '17 at 08:06
  • Look at the http://getquill.io/#extending-quill-custom-encoding section. Incase of json you can use any Json library you want. Just provide an appropriate codec to interface with underlying `java.sql.Types.OTHER`. – sarveshseri Apr 21 '17 at 11:24

1 Answers1

1

As Sarvesh mentioned it, it highly depends on the library you are going to use. There is a nice pg-slick extension (https://github.com/tminglei/slick-pg) that supports most of the json libraries.

As for the other libraries, I did not find any relevant resource. It is however possible to insert json with plain SQL. Find resource here

Community
  • 1
  • 1
Louis F.
  • 2,018
  • 19
  • 22