I am trying to hit an API and retreive JSON. I am trying to iterate on records and trying to fetch results. The problem is that below are the warnings which are being populated as errors. I don't want to make them as warnings, but to find out what may be the solution to match may not be exclusive error message.
case class Results(network: String,entity: String)
val jsonStr=parse(content)
val results = for {
JArray(results) <- jsonStr
JObject(result) <- results
JField("network",JString(network)) <- result
JField("entityId",JString(entityId)) <- result
} yield Results(network,entityId)
Output:
[error] /home/jenkins/builds/workspace/ProjectName/core/src/main/scala/Settlement_Feed.scala:42: match may not be exhaustive.
[error] It would fail on the following inputs: JArray(_), JBool(_), JDouble(_), JField(_, _), JInt(_), JNothing, JNull, JString(_)
[error] JObject(result) <- results
[error] ^
[error] /home/jenkins/builds/workspace/ProjectName/core/src/main/scala/Settlement_Feed.scala:41: match may not be exhaustive.
[error] It would fail on the following inputs: JBool(_), JDouble(_), JField(_, _), JInt(_), JNothing, JNull, JObject(_), JString(_)
[error] JArray(results) <- jsonStr
[error]
[error] two errors found
I have tried reading liftjson and scala docs for this, but couldn't find much of valuable information to resolve the error. I have tried keeping if loop and try to check instance of jsonstr, but it didn't work. Any suggestions is highly appreciated. Thanks a lot.