eclipsesource/play-json-schema-validator

Convert a SchemaType back to JSON

Closed this issue · 2 comments

Is it possible to convert a SchemaType back to JSON after it has been extracted?

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?

Oh wow yea that's exactly what I was going for. Thank you!