File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
src/main/scala/com/github/celadari/jsonlogicscala/core Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 11package com .github .celadari .jsonlogicscala .core
22
3- import play .api .libs .json .{JsValue , Reads }
3+ import play .api .libs .json .{JsObject , JsValue , Reads }
44
55object Decoder {
66 implicit val defaultDecoder : Decoder = new Decoder {
@@ -12,8 +12,12 @@ object Decoder {
1212abstract class Decoder {
1313 def customDecode (json : JsValue , otherType : String )(implicit reads : Array [Reads [_]]): Any
1414
15- def decode (jsValue : JsValue , `type` : String )(implicit reads : Array [Reads [_]] = Array ()): ValueLogic [_] = {
16- val value = `type` match {
15+ def decode (jsonLogic : JsObject , jsonLogicData : JsObject )(implicit reads : Array [Reads [_]] = Array ()): ValueLogic [_] = {
16+ val typeData = (jsonLogic \ " type" ).as[String ]
17+ val pathData = (jsonLogic \ " var" ).as[String ]
18+ val jsValue = (jsonLogicData \ pathData).get
19+
20+ val value = typeData match {
1721 case " byte" => jsValue.as[Byte ]
1822 case " short" => jsValue.as[Short ]
1923 case " int" => jsValue.as[Int ]
Original file line number Diff line number Diff line change @@ -10,10 +10,7 @@ object ValueLogic {
1010 }
1111
1212 private [core] def decode (jsonLogic : JsObject , jsonLogicData : JsObject )(implicit decoder : Decoder ): ValueLogic [_] = {
13- val typeData = (jsonLogic \ " type" ).as[String ]
14- val pathData = (jsonLogic \ " var" ).as[String ]
15- val json = (jsonLogicData \ pathData).get
16- ValueLogic (" var" , decoder.decode(json, typeData))
13+ ValueLogic (" var" , decoder.decode(jsonLogic, jsonLogicData))
1714 }
1815
1916 implicit def valueLogicReads [T ](implicit fmt : Reads [T ]): Reads [ValueLogic [T ]] = new Reads [ValueLogic [T ]] {
You can’t perform that action at this time.
0 commit comments