-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define JsonType #577
Comments
dont do that.
call to_primitive(), then call use a function to convert that to json
…On Sun, Nov 11, 2018, 2:44 PM Matúš Barabás ***@***.*** wrote:
Can someone help me how to create new JsonType ? My column in databese has
json type value.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#577>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADBiA4au7GYE3iK0qKv7ogZwICLUY6Dks5uuH4WgaJpZM4YYpda>
.
|
Can you explain more? What type i should use ? My custom or BaseType? and why i have to call to_primitive function? |
Just use a model.
Consider that Schematics is not far from being a typed dictionary already.
The only thing left for you to do is to call json.dumps
You can have a model with a field that is another model, which how I would
approach your usecase
…On Sun, Nov 11, 2018, 2:51 PM Matúš Barabás ***@***.*** wrote:
Can you explain more? What type i should use ? My custom or BaseType? and
why i have to call to_primitive function?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#577 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADBiMYeoWWBen3xRQN0uVQtQOviOO9-ks5uuH--gaJpZM4YYpda>
.
|
This is model, which I used. So, I have to change
And where to use |
uhh what?! json as a validator?
the whole point of the to_primitive and to_native functions is to convert
data to and form python native form to a form that is acceptable to
language agnostic encodings, like json
validators are intended to check if the data looks the way the type requires
your code sample appears to conflate these two concepts, tho I cant be sure
i urge you to read the docs and get a good mental model for schematics in
your head. the gist of your second sample is going in the right direction,
but is not yet correct. the docs will get you there.
…On Sun, Nov 11, 2018, 3:07 PM Matúš Barabás ***@***.*** wrote:
class CreateRequest(Model):
id: IntType = IntType(required=False)
param: StringType = StringType(validators=[json_validator])
This is model, which I used. So, I have to change StringType to Model
like this?
class CreateRequest(Model):
id: IntType = IntType(required=False)
param: Model
And where to use json dumps method. It is still not clear for me.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#577 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADBiDscXjFRy495pwCYtyvTy52a6Bljks5uuIN-gaJpZM4YYpda>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can someone help me how to create new JsonType ? My column in databese has json type value.
The text was updated successfully, but these errors were encountered: