A com.rojoma.json.v3.matcher.Pattern which matches only if all the sub-patterns also match.
Simple class to turn a com.rojoma.json.v3.codec.JsonDecode into something that can be used for pattern-matching.
Simple class to turn a com.rojoma.json.v3.codec.JsonDecode into something that can be used for pattern-matching.
val ListOfFoo = DecodeMatcher[List[Foo]] val NamedBars = DecodeMatcher[Map[String, Bar]] value match { case ListOfFoo(foos) => foos.foreach(_.fooify()) case NamedBars(bars) => bars("hello").doBarring() case _ => // didn't match }
A com.rojoma.json.v3.matcher.Pattern which matches a com.rojoma.json.v3.ast.JValue if a predicate on that JValue is true.
A com.rojoma.json.v3.matcher.Pattern which matches a com.rojoma.json.v3.ast.JValue
if a predicate on that JValue is true. This Pattern
cannot be used to generate a
com.rojoma.json.v3.ast.JValue.
A com.rojoma.json.v3.matcher.Pattern which matches the first sub-pattern to succeed.
A com.rojoma.json.v3.matcher.Pattern which matches the first
sub-pattern to succeed. This is frequently used to allow a
value to be something-or-null
.
A com.rojoma.json.v3.matcher.Pattern which matches a com.rojoma.json.v3.ast.JValue exactly.
A com.rojoma.json.v3.matcher.Pattern which matches a com.rojoma.json.v3.ast.JValue
exactly. Generally this is not used explicitly; com.rojoma.json.v3.ast.JValues
can be implicitly converted into Literal
s.
Either a com.rojoma.json.v3.matcher.Pattern or a com.rojoma.json.v3.matcher.POption.
A com.rojoma.json.v3.matcher.Pattern which matches if the value is a com.rojoma.json.v3.ast.JArray which contains at least as many elements as sub-patterns contained by this object and those elements match the sub-patterns in the order given.
A com.rojoma.json.v3.matcher.Pattern which matches if the value is a com.rojoma.json.v3.ast.JArray which contains at least as many elements as sub-patterns contained by this object and those elements match the sub-patterns in the order given.
For the more common case where a sequence of repeated objects of a
particular type is desired, use a com.rojoma.json.v3.matcher.Variable
of some Seq[T]
.
A com.rojoma.json.v3.matcher.Pattern which matches if the value is
a com.rojoma.json.v3.ast.JObject which contains at least the fields
specified in this Pattern
.
A com.rojoma.json.v3.matcher.Pattern which matches if the value is
a com.rojoma.json.v3.ast.JObject which contains at least the fields
specified in this Pattern
. In order to allow fields to not appear
at all, the sub-patterns can be wrapped in a com.rojoma.json.v3.matcher.POption.
val i = Variable[Int] val s = Variable[String] val b = Variable[Boolean] val f = Variable[Float] val pattern = PObject( "i" -> i, // must be present "s" -> POption(s), // may be absent but must not be null "b" -> POption(b).orNull, // may be present, absent, or null "f" -> FirstOf(f, JNull) // must be present but may be null ) pattern.matches(jvalue) match { case Some(results) => println("i: " + i(results)) println("s: " + s.getOrElse(results, "[not present]")) println("b: " + b.getOrElse(results, "[not present or null]")) println("f: " + f.getOrElse(results, "[null]")) case None => println("Didn't match") }
A wrapper for a com.rojoma.json.v3.matcher.Pattern which allows fields to be absent when using a com.rojoma.json.v3.matcher.PObject.
A wrapper for a com.rojoma.json.v3.matcher.Pattern which allows fields to be absent when using a com.rojoma.json.v3.matcher.PObject.
An object that can be used to either match and extract data from, or generate, com.rojoma.json.v3.ast.JValues.
A com.rojoma.json.v3.matcher.Pattern which matches any com.rojoma.json.v3.ast.JValue
which can be decoded into an object of type T
.
A com.rojoma.json.v3.matcher.Pattern which matches any com.rojoma.json.v3.ast.JValue
which can be decoded into an object of type T
. If this variable is
already bound in the environment at match-time, then this matches only if
the two decoded objects are equal
, in which case the environment is
unchanged.
A com.rojoma.json.v3.matcher.Pattern which matches only if all the sub-patterns also match. This pattern cannot be used to
generate
a com.rojoma.json.v3.ast.JValue.