jdorn / json-editor

JSON Schema Based Editor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

oneOf return values

GeorgiSK opened this issue · comments

Hi,

I'm trying to make a schema where i have one object with 2 properties. The first property is a combobox (select) and the second property is an array of strings. So i want to change the contents of the array, based on the value of the first property. Since i'm not able for some reason to use definitions, i thought that i could do this with oneOf . This looks and works great but the problem is that the return value only contains the contents of the array and not the chosen value in the oneOf combobox... Is there a way to get that value or possibly a different implementation?

Here is my code:

"type": "object",
"title": "TITLE",
"properties": {
"prop1": {
"oneOf": [{
"type": "array",
"format": "checkbox",
"title": "Option1",
"items": {
"type": "string",
"enum": ["Option1Val1", "Option1Val2"]
},
"uniqueItems": true
}, {
"type": "array",
"title": "Option2",
"format": "checkbox",
"items": {
"type": "string",
"enum": ["Option2Val1", "Option2Val2"]
},
"uniqueItems": true
}
]
},
"show_errors": "always"
}

The result looks like that if i choose option1 and all the values in the array:
{"prop1": ["Option1Val1", "Option1Val2"]}

and i need something like:
{"prop1": {"Option1": ["Option1Val1", "Option1Val2"]}}