JSON Schema - dropdown based on selected value other dropdown










2














Lets say i've the following data structure



Option A
Option B
Option B1
Option B2.1
Option B2.2


I am trying to create an enums stucture that allows this so I can generate a dropdown based on the value of the previous selected dropdown.



Examples :



Select option A -> No additional dropdowns
Select option B -> Generate dropdown with Option B1
Select option B1 -> Generate dropdown with Option B2.1 and Option B2.2


This would work when you want to create an array with childeren is there anything similar possible for enums




"$schema": "http://json-schema.org/draft-07/schema#",

"definitions":
"medicine":
"type": "object",
"properties":
"value": "type": "string" ,
"categories":
"type": "array",
"items": "$ref": "#/definitions/medicine"



,
"properties":
"person": "$ref": "#/definitions/medicine"





And then the enum structure to be something like this



[

"value ": "Option A"
,

"value ": "Option B ",
"categories ": [

"value ": "Option B1 ",
"categories ": [

"value ": "Option B1.1"
,

"value ": "Option B1.2"

]

]

]


So I am looking for a data structure that would allow me to make dropdowns based on the values selected here in a own layout generation engine.










share|improve this question























  • JSON Schema was not designed for form generation. In other words, there is no standard for generating a form from a JSON Schema. Every implementation does it their own way. So, whatever answer there might be to this question, it will necessarily be implementation specific. That said, I'm not aware of any implementation that supports form generation of this complexity.
    – Jason Desrosiers
    Nov 13 at 3:15










  • What is exactly that you look for? Are you asking about JSON schema that reflects described dependencies?
    – PsychoFish
    Nov 15 at 19:44















2














Lets say i've the following data structure



Option A
Option B
Option B1
Option B2.1
Option B2.2


I am trying to create an enums stucture that allows this so I can generate a dropdown based on the value of the previous selected dropdown.



Examples :



Select option A -> No additional dropdowns
Select option B -> Generate dropdown with Option B1
Select option B1 -> Generate dropdown with Option B2.1 and Option B2.2


This would work when you want to create an array with childeren is there anything similar possible for enums




"$schema": "http://json-schema.org/draft-07/schema#",

"definitions":
"medicine":
"type": "object",
"properties":
"value": "type": "string" ,
"categories":
"type": "array",
"items": "$ref": "#/definitions/medicine"



,
"properties":
"person": "$ref": "#/definitions/medicine"





And then the enum structure to be something like this



[

"value ": "Option A"
,

"value ": "Option B ",
"categories ": [

"value ": "Option B1 ",
"categories ": [

"value ": "Option B1.1"
,

"value ": "Option B1.2"

]

]

]


So I am looking for a data structure that would allow me to make dropdowns based on the values selected here in a own layout generation engine.










share|improve this question























  • JSON Schema was not designed for form generation. In other words, there is no standard for generating a form from a JSON Schema. Every implementation does it their own way. So, whatever answer there might be to this question, it will necessarily be implementation specific. That said, I'm not aware of any implementation that supports form generation of this complexity.
    – Jason Desrosiers
    Nov 13 at 3:15










  • What is exactly that you look for? Are you asking about JSON schema that reflects described dependencies?
    – PsychoFish
    Nov 15 at 19:44













2












2








2


2





Lets say i've the following data structure



Option A
Option B
Option B1
Option B2.1
Option B2.2


I am trying to create an enums stucture that allows this so I can generate a dropdown based on the value of the previous selected dropdown.



Examples :



Select option A -> No additional dropdowns
Select option B -> Generate dropdown with Option B1
Select option B1 -> Generate dropdown with Option B2.1 and Option B2.2


This would work when you want to create an array with childeren is there anything similar possible for enums




"$schema": "http://json-schema.org/draft-07/schema#",

"definitions":
"medicine":
"type": "object",
"properties":
"value": "type": "string" ,
"categories":
"type": "array",
"items": "$ref": "#/definitions/medicine"



,
"properties":
"person": "$ref": "#/definitions/medicine"





And then the enum structure to be something like this



[

"value ": "Option A"
,

"value ": "Option B ",
"categories ": [

"value ": "Option B1 ",
"categories ": [

"value ": "Option B1.1"
,

"value ": "Option B1.2"

]

]

]


So I am looking for a data structure that would allow me to make dropdowns based on the values selected here in a own layout generation engine.










share|improve this question















Lets say i've the following data structure



Option A
Option B
Option B1
Option B2.1
Option B2.2


I am trying to create an enums stucture that allows this so I can generate a dropdown based on the value of the previous selected dropdown.



Examples :



Select option A -> No additional dropdowns
Select option B -> Generate dropdown with Option B1
Select option B1 -> Generate dropdown with Option B2.1 and Option B2.2


This would work when you want to create an array with childeren is there anything similar possible for enums




"$schema": "http://json-schema.org/draft-07/schema#",

"definitions":
"medicine":
"type": "object",
"properties":
"value": "type": "string" ,
"categories":
"type": "array",
"items": "$ref": "#/definitions/medicine"



,
"properties":
"person": "$ref": "#/definitions/medicine"





And then the enum structure to be something like this



[

"value ": "Option A"
,

"value ": "Option B ",
"categories ": [

"value ": "Option B1 ",
"categories ": [

"value ": "Option B1.1"
,

"value ": "Option B1.2"

]

]

]


So I am looking for a data structure that would allow me to make dropdowns based on the values selected here in a own layout generation engine.







json dropdown jsonschema json-schema-validator






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 13:42

























asked Nov 9 at 13:37









Joey

9011




9011











  • JSON Schema was not designed for form generation. In other words, there is no standard for generating a form from a JSON Schema. Every implementation does it their own way. So, whatever answer there might be to this question, it will necessarily be implementation specific. That said, I'm not aware of any implementation that supports form generation of this complexity.
    – Jason Desrosiers
    Nov 13 at 3:15










  • What is exactly that you look for? Are you asking about JSON schema that reflects described dependencies?
    – PsychoFish
    Nov 15 at 19:44
















  • JSON Schema was not designed for form generation. In other words, there is no standard for generating a form from a JSON Schema. Every implementation does it their own way. So, whatever answer there might be to this question, it will necessarily be implementation specific. That said, I'm not aware of any implementation that supports form generation of this complexity.
    – Jason Desrosiers
    Nov 13 at 3:15










  • What is exactly that you look for? Are you asking about JSON schema that reflects described dependencies?
    – PsychoFish
    Nov 15 at 19:44















JSON Schema was not designed for form generation. In other words, there is no standard for generating a form from a JSON Schema. Every implementation does it their own way. So, whatever answer there might be to this question, it will necessarily be implementation specific. That said, I'm not aware of any implementation that supports form generation of this complexity.
– Jason Desrosiers
Nov 13 at 3:15




JSON Schema was not designed for form generation. In other words, there is no standard for generating a form from a JSON Schema. Every implementation does it their own way. So, whatever answer there might be to this question, it will necessarily be implementation specific. That said, I'm not aware of any implementation that supports form generation of this complexity.
– Jason Desrosiers
Nov 13 at 3:15












What is exactly that you look for? Are you asking about JSON schema that reflects described dependencies?
– PsychoFish
Nov 15 at 19:44




What is exactly that you look for? Are you asking about JSON schema that reflects described dependencies?
– PsychoFish
Nov 15 at 19:44












1 Answer
1






active

oldest

votes


















4





+25









Have you considered flattening your structure so that it's easier to look up options and sub-options?



Let's imagine that you've got an initial array for the root options:



[
'opt_a',
'opt_b'
]


Then you have a flattened map of all options from which you can derive labels and subsequent dropdowns:




opt_a:
label: 'Option A'
,
opt_b:
label: 'Option B',
children: ['opt_b1']
,
opt_b1:
label: 'Option B1',
children: ['opt_b11', 'opt_b12']

opt_b11:
label: 'Option B1.1'

opt_b12:
label: 'Option B1.2'




I hope this answers your question and is self-explanatory enough.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53226772%2fjson-schema-dropdown-based-on-selected-value-other-dropdown%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4





    +25









    Have you considered flattening your structure so that it's easier to look up options and sub-options?



    Let's imagine that you've got an initial array for the root options:



    [
    'opt_a',
    'opt_b'
    ]


    Then you have a flattened map of all options from which you can derive labels and subsequent dropdowns:




    opt_a:
    label: 'Option A'
    ,
    opt_b:
    label: 'Option B',
    children: ['opt_b1']
    ,
    opt_b1:
    label: 'Option B1',
    children: ['opt_b11', 'opt_b12']

    opt_b11:
    label: 'Option B1.1'

    opt_b12:
    label: 'Option B1.2'




    I hope this answers your question and is self-explanatory enough.






    share|improve this answer



























      4





      +25









      Have you considered flattening your structure so that it's easier to look up options and sub-options?



      Let's imagine that you've got an initial array for the root options:



      [
      'opt_a',
      'opt_b'
      ]


      Then you have a flattened map of all options from which you can derive labels and subsequent dropdowns:




      opt_a:
      label: 'Option A'
      ,
      opt_b:
      label: 'Option B',
      children: ['opt_b1']
      ,
      opt_b1:
      label: 'Option B1',
      children: ['opt_b11', 'opt_b12']

      opt_b11:
      label: 'Option B1.1'

      opt_b12:
      label: 'Option B1.2'




      I hope this answers your question and is self-explanatory enough.






      share|improve this answer

























        4





        +25







        4





        +25



        4




        +25




        Have you considered flattening your structure so that it's easier to look up options and sub-options?



        Let's imagine that you've got an initial array for the root options:



        [
        'opt_a',
        'opt_b'
        ]


        Then you have a flattened map of all options from which you can derive labels and subsequent dropdowns:




        opt_a:
        label: 'Option A'
        ,
        opt_b:
        label: 'Option B',
        children: ['opt_b1']
        ,
        opt_b1:
        label: 'Option B1',
        children: ['opt_b11', 'opt_b12']

        opt_b11:
        label: 'Option B1.1'

        opt_b12:
        label: 'Option B1.2'




        I hope this answers your question and is self-explanatory enough.






        share|improve this answer














        Have you considered flattening your structure so that it's easier to look up options and sub-options?



        Let's imagine that you've got an initial array for the root options:



        [
        'opt_a',
        'opt_b'
        ]


        Then you have a flattened map of all options from which you can derive labels and subsequent dropdowns:




        opt_a:
        label: 'Option A'
        ,
        opt_b:
        label: 'Option B',
        children: ['opt_b1']
        ,
        opt_b1:
        label: 'Option B1',
        children: ['opt_b11', 'opt_b12']

        opt_b11:
        label: 'Option B1.1'

        opt_b12:
        label: 'Option B1.2'




        I hope this answers your question and is self-explanatory enough.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 15 at 10:05

























        answered Nov 14 at 14:05









        customcommander

        1,173617




        1,173617



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53226772%2fjson-schema-dropdown-based-on-selected-value-other-dropdown%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            27

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            Category:Rhetoric