wolverdude / GenSON

GenSON is a powerful, user-friendly JSON Schema generator built in Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get only content from schema ?

Yawan-1 opened this issue · comments

commented

I am trying to get only content from the schema. But when I try to access it like

builder.to_schema().content

then it keep says

AttributeError: 'str' object has no attribute 'content'

Hi Yawan!

to_schema() returns a dict, not an object, so you have to access its data using square brackets (e.g. builder.to_schema()["content"]). But that would still give you an error since there is no content keyword in JSON-Schema that I'm aware of. Perhaps you want to get the schema for the content property in the original object? If so, then you'll need to do something like this:

builder.to_schema()["properties"]["content"]

If that's not what you mean by "content", then please specify. I'll go ahead and close this issue now, since it isn't a problem with GenSON's features.