File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change 11package jsonrpclib
22
33import com .github .plokhotnyuk .jsoniter_scala .core ._
4+ import scala .annotation .switch
45
56sealed trait CallId
67object CallId {
@@ -10,17 +11,13 @@ object CallId {
1011
1112 implicit val callIdRW : JsonValueCodec [CallId ] = new JsonValueCodec [CallId ] {
1213 def decodeValue (in : JsonReader , default : CallId ): CallId = {
13- try {
14- NumberId (in.readLong())
15- } catch {
16- case _ : JsonReaderException =>
17- in.rollbackToken()
18- try {
19- StringId (in.readString(null ))
20- } catch {
21- case _ : JsonReaderException =>
22- in.readNullOrError(default, " expected null" )
23- }
14+ val nt = in.nextToken()
15+
16+ (nt : @ switch) match {
17+ case 'n' => in.readNullOrError(default, " expected null" )
18+ case '"' => in.rollbackToken(); StringId (in.readString(null ))
19+ case _ => in.rollbackToken(); NumberId (in.readLong())
20+
2421 }
2522 }
2623
You can’t perform that action at this time.
0 commit comments