Question

Dynamic list attribute to JSON Response format

  • 16 April 2021
  • 6 replies
  • 20 views

Badge

I'm trying to read select multiple survey123 form responses dynamically to create a JSON template. The number of selections from a list of 24 values of tree diseases is in the survey, The feature service captures these multiple responses as comma-separated values. each comma-separated value is represented in JSON format for the HTTP caller to make an API request.

each disease type has a unique answerID

How to dynamically create JSON template from the number of list elements in the attribute splitter


6 replies

Do you need to create a JSON document (middle image) based on the list attribute "_treediseaseList" (left image)?

If so, where the IDs (AnswerID, InspectionID, QuestionID) corresponding to each AnswerValue (disease name) are come from?

Badge

Do you need to create a JSON document (middle image) based on the list attribute "_treediseaseList" (left image)?

If so, where the IDs (AnswerID, InspectionID, QuestionID) corresponding to each AnswerValue (disease name) are come from?

Hello @Takashi Iijima​ ,

I'm populating a Cityworks Inspection Template based on these values, In the template, each question and answer option have ID's

If it was select one question I use an attribute creator and JSON Templater to make up the JSON for the request. For a select multiple there is no way to know ahead how many of these list items will be selected. The Inspection ID comes from the HTTPCaller response body which I extract using a JSON Extractor.CityworksObservationQuestionQuestionAnswerID

Userlevel 2
Badge +17

I think the first screenshot in your question is the source table which you need to convert to a JSON document, and I guess that the source table contains some attributes storing the IDs (question ID etc.), similar to the attribute called "treedisease" storing comma-separated tree disease names.

If so, could please share the source table?

Badge

I think the first screenshot in your question is the source table which you need to convert to a JSON document, and I guess that the source table contains some attributes storing the IDs (question ID etc.), similar to the attribute called "treedisease" storing comma-separated tree disease names.

If so, could please share the source table?

Hello @Takashi Iijima​ 

please find the excel containing the QuestionID and AnswerID,attached here

Thankyou

Badge

Hello @Takashi Iijima​ 

please find the excel containing the QuestionID and AnswerID,attached here

Thankyou

This is the correct table

Userlevel 2
Badge +17

Hello @Takashi Iijima​ 

please find the excel containing the QuestionID and AnswerID,attached here

Thankyou

The attached workspace demonstrates how you can translate the Excel table to a JSON array.jsontempater-example

Reply