Skip to content

JSON and JSONB fields from a Piccolo Table is being serialized as strings in PiccoloCRUD #233

Answered by sinisaos
hoosnick asked this question in Q&A
Discussion options

You must be logged in to vote

@hoosnick Yes of course. You can create two separate models and routes for it, like in the piccolo asgi template. In out model you can pass deserialize_json=True like this

CourseModelIn: t.Any = create_pydantic_model(
    table=Course,
    model_name='CourseModelIn'
)
CourseModelOut: t.Any = create_pydantic_model(
    table=Course,
    include_default_columns=True,
    deserialize_json=True,
    model_name='CourseModelOut'
)

Hope that helps.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hoosnick
Comment options

@sinisaos
Comment options

Answer selected by hoosnick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants