org.json4sbt.DynamicJValue.scala Maven / Gradle / Ivy
The newest version!
package org.json4sbt
import scala.language.dynamics
class DynamicJValue(val raw: JValue) extends Dynamic {
/**
* Adds dynamic style to JValues. Only meaningful for JObjects
*
* Example:
* JObject(JField("name",JString("joe"))::Nil).name == JString("joe")
*
*/
def selectDynamic(name:String) = new DynamicJValue(raw \ name)
override def hashCode():Int = raw.hashCode
override def equals(p1: Any): Boolean = p1 match {
case j: DynamicJValue => raw == j.raw
case j: JValue => raw == j
case _ => false
}
}
trait DynamicJValueImplicits {
implicit def dynamic2Jv(dynJv: DynamicJValue) = dynJv.raw
implicit def dynamic2monadic(dynJv: DynamicJValue) = new MonadicJValue(dynJv.raw)
def dyn(jv:JValue) = new DynamicJValue(jv)
}
object DynamicJValue extends DynamicJValueImplicits
© 2015 - 2025 Weber Informatics LLC | Privacy Policy