Convert a SchemaType back to JSON
Closed this issue · 2 comments
amilkov1 commented
Is it possible to convert a SchemaType
back to JSON after it has been extracted?
edgarmueller commented
You mean to a JsValue
? Yes, that possible via Play's Json.toJson
, e.g. in the tests we do:
val stringConstraint = """{ "maxLength": 2 }"""
val schema: SchemaType = JsonSource.schemaFromString(stringConstraint).get
Json.toJson(schema) must beEqualTo(Json.obj("maxLength" -> 2))
Does this answer your question?
amilkov1 commented
Oh wow yea that's exactly what I was going for. Thank you!