5

Source of truth is a jsonschema file/string which I wish to utilise to build objects as using validations etc.

Does Marshmallow allow to define schema using a JsonSchema rather than manually place the fields?

So presently what I do is,

  1. Take in serialized JSON data.
  2. Deserialize it to Python Dictionary
  3. Validate that python dictionary using python-jsonschema library.

So I then know that my json is good enough then the steps to serialize it to Python Object using marshmallow will follow as I know my data is validated correctly.

What I wish to achieve is gain the validation part within marshmallow using jsonschema, so to avoid using additional libraries and having multiple steps.

Isaac Philip
  • 498
  • 1
  • 5
  • 14
  • You can't really do this for a relational database, as JSON has multiple layers of data, and JSON Schema has conditionality and other things a relational database wouldn't be able to easily support. You may build your own adaptor for simple JSON Schemas for your own use, but full JSON Schema support would be next to impossible, and you're likely to want to express things in your ORM schema that you cannot in JSON Schema. – Relequestual Feb 28 '19 at 15:50
  • Have you looked at their documentation? – Relequestual Feb 28 '19 at 15:51
  • To my knowledge, no, there is no JSONSchema -> Marshmallow converter. – Jérôme Mar 02 '19 at 20:56
  • For the other way you have this: https://pypi.org/project/marshmallow-jsonschema/ – user2340939 Sep 04 '22 at 13:19

0 Answers0