2017-03-28 37 views
1

升級瑟茜不成形記錄從0.4.1到0.7.0打破了下面的代碼:編碼/解碼與瑟茜

import shapeless._ 
import syntax.singleton._ 
import io.circe.generic.auto._ 

.run[Record.`'transaction_id -> Int`.T](transport) 

def run[A](transport: Json => Future[Json])(implicit decoder: Decoder[A], exec: ExecutionContext): Future[A] 

,出現以下錯誤:

could not find implicit value for parameter decoder: io.circe.Decoder[shapeless.::[Int with shapeless.labelled.KeyTag[Symbol with shapeless.tag.Tagged[String("transaction_id")],Int],shapeless.HNil]] 
[error]  .run[Record.`'transaction_id -> Int`.T](transport) 
[error]           ^

我失去了一些進口這裏還是這些編碼器/解碼器不再適用於circe?

回答

1

實例爲無形的hlists,記錄等在瑟茜0.6.0版本被轉移到一個獨立的瑟茜形模塊。如果將此模塊添加到您的構建,下面應該只是工作:

import io.circe.jawn.decode, io.circe.shapes._ 
import shapeless._, record.Record, syntax.singleton._ 

val doc = """{ "transaction_id": 1 }""" 

val res = decode[Record.`'transaction_id -> Int`.T](doc) 

移動這些實例的動機是,改進後的通用推導引入0.6意味着他們不再是必要的,讓他們出來的不是在需要時隱範圍既清潔和潛在支持更快的編譯時間。新瑟茜形模塊還包括那些不提供瑟茜-通用功能,如副產品實例。

+0

許多感謝。在任何地方都找不到分割。 – simao