surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.12k stars 802 forks source link

Support the jsonPath for Choices RESTful #8092

Closed JaneSjs closed 5 months ago

JaneSjs commented 5 months ago

Suggestion: support the jsonPath for Choices RESTful. An example of a JSON path: The input JSON:

[
   {
      "name":"Italy",
      "regionsList":[
         {
            "name":"Lombardia",
            "capitalCity":"Milano",
            "ProvinceList":[
               {
                  "name":"Milano",
                  "code":"MI"
               },
               {
                  "name":"Brescia",
                  "code":"BR"
               }
            ]
         },
         {
            "name":"Lazio",
            "capitalCity":"Rome",
            "ProvinceList":[
               {
                  "name":"Rome",
                  "code":"RM"
               },
               {
                  "name":"Latina",
                  "code":"LT"
               }
            ]
         },
         {
            "name":"Campania",
            "capitalCity":"Naples",
            "ProvinceList":[
               {
                  "name":"Naples",
                  "code":"NA"
               },
               {
                  "name":"Salerno",
                  "code":"SA"
               }
            ]
         }
      ]
   }
]

jsonPath: $..regionsList..ProvinceList[*] You can test this in an online service: https://jsonpath.com/

andrewtelnov commented 5 months ago

@JaneSjs It is better to use a jsonpath library. It can be used in survey.onLoadChoicesFromServer event.

Thank you, Andrew