Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

trialing some string wraps to assist with building objects of options

  • Loading branch information...
commit c5af3980ce82875fea90c2d39f126a3826e463e6 1 parent bcd3413
markhibberd authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/main/scala/com/ephox/argonaut/StringWrap.scala
View
13 src/main/scala/com/ephox/argonaut/StringWrap.scala
@@ -82,6 +82,19 @@ sealed trait StringWrap {
* Parses this string value to a possible JSON value.
*/
def pparse: Option[Json] = parseIgnoreError(Some(_), None)
+
+ /*
+ * Construct a pair of the key and JSON value.
+ */
+ def :=[A: EncodeJson](a: A) =
+ (value, implicitly[EncodeJson[A]].apply(a))
+
+ /*
+ * Construct a pair of the key and JSON value.
+ */
+ def :=?[A: EncodeJson](a: Option[A]) =
+ a map (aa => (value, implicitly[EncodeJson[A]].apply(aa)))
+
}
object StringWrap extends StringWraps
Please sign in to comment.
Something went wrong with that request. Please try again.