You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the difficulty here is that the enum dropdown only works when the JSON matches the JSONSchema, whilst a template can be inserted everywhere. In your example code the enum for gender only works for a property in the root object, and not for nested objects. When inserting an employee via the template, you create a nested object - which is not matching the JSON Schema enum.
will only create a dropdown for the field gender in the root of the JSON object like:
{
"gender": "male"
}
It will NOT create a dropdown not for nested objects like here:
{
"someNestedObject": {
"gender": "male"
}
}
if you need that, you will need to adjust your JSON Schema to have the definition of gender there where it will be created in your JSON object. If you want a dropdown for gender everywhere in the object (on all levels), you will have to define a JSON Schema with recursion like discussed here.
I have followed this conversation and tried everything you suggested, but I can not get a dropdown to show up anywhere but on the top level of the schema for an enum property like gender.
Do you have plans to make dropdown available on any level?
Also, what is the relation between jsoneditor and json-editor projects. I like jsoneditir, but json-editor does handle enums a sdropdowns on any level of the schema
Activity
josdejong commentedon Oct 7, 2017
These enum dropdowns are a feature that you can use by providing a JSON Schema enumeration, so you could use it in combination with a template.
sumancholleti commentedon Oct 8, 2017
Can you give an example, I tried this , its not showing dropdown
josdejong commentedon Oct 9, 2017
Here you go:
http://jsbin.com/ciqifub/edit?html,output
sumancholleti commentedon Oct 10, 2017
Can json be an object instead?
josdejong commentedon Oct 10, 2017
yes. just play around with it and you will see
sumancholleti commentedon Oct 10, 2017
I tried and it didn't work
josdejong commentedon Oct 10, 2017
Keep trying :)
You will have to adjust both JSON and JSON schema, these need to be aligned with each other.
sumancholleti commentedon Oct 10, 2017
No luck yet
var schema = {
"type": "object",
"properties": {
"gender": {
"enum": ["male", "female"]
}
}
};
josdejong commentedon Oct 11, 2017
I think the difficulty here is that the enum dropdown only works when the JSON matches the JSONSchema, whilst a template can be inserted everywhere. In your example code the enum for
gender
only works for a property in the root object, and not for nested objects. When inserting an employee via the template, you create a nested object - which is not matching the JSON Schema enum.sumancholleti commentedon Oct 11, 2017
I didn't get you
josdejong commentedon Oct 16, 2017
The schema that you post:
will only create a dropdown for the field
gender
in the root of the JSON object like:It will NOT create a dropdown not for nested objects like here:
if you need that, you will need to adjust your JSON Schema to have the definition of
gender
there where it will be created in your JSON object. If you want a dropdown forgender
everywhere in the object (on all levels), you will have to define a JSON Schema with recursion like discussed here.ortrud commentedon Jan 17, 2018
I have followed this conversation and tried everything you suggested, but I can not get a dropdown to show up anywhere but on the top level of the schema for an enum property like gender.
Do you have plans to make dropdown available on any level?
Also, what is the relation between jsoneditor and json-editor projects. I like jsoneditir, but json-editor does handle enums a sdropdowns on any level of the schema
josdejong commentedon Jan 18, 2018
@ortrud have you tried the example that I posted here? http://jsbin.com/ciqifub/edit?html,output
There is no relation between jsoneditor and json-editor except that they are both editors for JSON :)
If your json schema defines enums on any level, then JSONEditor will display them on any level - that's a matter of how you define your json schema.
SteveNeithardt commentedon Aug 22, 2018
I have the same issue, where the enums drop downs never seem to appear within objects in arrays.
Here's the screenshot of the example you posted on jsbin.
22 remaining items