How to render checkbox component if data contains 1 or 0

Here is what my schema:
{
“type”: “object”,
“properties”: {
“name”: {
“type”: “string”,
“minLength”: 3
},
“vegetarian”: {
“type”: “boolean”
}
}
}

my data is coming from mysql database, since mysql does not support booleans, the column vegetarian is of type tinyint . Hence the values are 0 or 1

Problem is that with 0 and 1 in data the boolean controls are also rendered as textbox instead of checkbox.
I cannot change mysql data as its coming from data service.
How can i force to render checkbox even if data consists of 0 or 1?

[original thread by kashifxs]

[Naushad Rahman]

you can create custom Renderers . GitHub - eclipsesource/jsonforms-react-seed: React-based JSON Forms Seed App .

Hi @xs-kashif, I can’t reproduce the described issue. The type of input which is shown depends on the type defined in the JSON schema. So if the type is boolean we’ll definitely render a checkbox. As 0 and 1 are also compatible with boolean the checked state of the checkbox will also be correct. However once the user changes the state of the checkbox, the data will be transformed to a real boolean, i.e. true or false. If you want to keep using0and1` in your data instead I would either recommend to implement a custom renderer or transforming the data once before sending it back to your database.

We also offer to render JSON Forms without any JSON schema and ui schema only based on your data. In these cases we try to infer the JSON schema from the provided data object. There we would encounter the 1 or 0 property and assume that this is a number input and therefore don’t render a checkbox. So please make sure that you actually provide your JSON Schema to JSON Forms :wink: If you still encounter problems, it would be great if you could share your code if possible or showcase a minimal example which repdroduces the behavior.