We have a JSON String which looks like this:
{
"responseCode": 200,
"message": "success",
"content": {
"1": {
"headerType": "Large",
"imageAlign": "Left",
"name": "clickTo",
"nextButtonText": "Next",
"order": "2",
"previousButtonText": "Previous",
"qid": "1",
"showQuestionCount": "Yes",
"text": "Customer Details:",
"textAlign": "Left",
"type": "control_head",
"verticalTextAlign": "Middle"
},
"2": {
"buttonAlign": "Left",
"buttonStyle": "None",
"clear": "No",
"clearText": "Clear Form",
"encryptIcon": "No",
"name": "Button",
"order": "14",
"print": "No",
"printText": "Print Form",
"qid": "2",
"text": "Submit",
"type": "control_button"
},
"3": {
"labelAlign": "Auto",
"middle": "No",
"name": "fullName3",
"order": "3",
"prefix": "No",
"qid": "3",
"readonly": "No",
"required": "Yes",
"sublabels": {
"prefix": "Prefix",
"first": "First Name",
"middle": "Middle Name",
"last": "Last Name",
"suffix": "Suffix"
},
"suffix": "No",
"text": "Full Name",
"type": "control_fullname"
},
"4": {
"countryDropdownDefaultText": "Please Select",
"customCountryDropdown": "No",
"hasAutocomplete": "No",
"hasGeolocation": "No",
"labelAlign": "Auto",
"name": "address4",
"order": "4",
"qid": "4",
"required": "Yes",
"requiredInputs": "st1|state|city|zip|country",
"states": "textbox",
"subfields": "state|zip|st1|city|st2",
"sublabels": {
"cc_firstName": "First Name",
"cc_lastName": "Last Name",
"cc_number": "Credit Card Number",
"cc_ccv": "Security Code",
"cc_exp_month": "Expiration Month",
"cc_exp_year": "Expiration Year",
"addr_line1": "Street Address",
"addr_line2": "Street Address Line 2",
"city": "City",
"state": "State / Province",
"postal": "Postal / Zip Code",
"country": "Country"
},
"text": "Address",
"type": "control_address"
},
"5": {
"countryCode": "No",
"inputMask": "enable",
"inputMaskValue": "(###) ###-####",
"labelAlign": "Auto",
"name": "phoneNumber5",
"order": "5",
"qid": "5",
"readonly": "No",
"required": "Yes",
"sublabels": {
"area": "Area Code",
"phone": "Phone Number"
},
"text": "Phone Number",
"type": "control_phone"
},
"6": {
"allowCustomDomains": "No",
"confirmation": "No",
"confirmationHint": "Confirm Email",
"confirmationSublabel": "Confirm Email",
"disallowFree": "No",
"domainCheck": "No",
"hint": "ex: [email protected]",
"labelAlign": "Auto",
"name": "email6",
"order": "6",
"qid": "6",
"readonly": "No",
"required": "No",
"size": "310",
"subLabel": "[email protected]",
"text": "E-mail",
"type": "control_email",
"validation": "Email",
"verificationCode": "No"
},
"7": {
"name": "clickTo7",
"order": "7",
"qid": "7",
"text": "<hr />",
"type": "control_text"
},
"8": {
"labelAlign": "Auto",
"multipleSelections": "No",
"name": "howDid8",
"options": "Newspaper|Internet|Magazine|Other (Please specify...)",
"order": "8",
"qid": "8",
"required": "Yes",
"searchText": "Search",
"shuffle": "No",
"size": "0",
"special": "None",
"text": "How did you hear about us?",
"type": "control_dropdown",
"visibleOptions": "1",
"width": "310"
},
"9": {
"hint": " ",
"labelAlign": "Auto",
"name": "other",
"order": "9",
"qid": "9",
"readonly": "No",
"required": "Yes",
"size": "310",
"text": "Other",
"type": "control_textbox",
"validation": "None"
},
"11": {
"cols": "648",
"entryLimit": "None-0",
"entryLimitMin": "None-0",
"labelAlign": "Auto",
"mde": "No",
"name": "feedbackAbout11",
"order": "10",
"qid": "11",
"readonly": "No",
"required": "No",
"rows": "163",
"text": "Feedback about us:",
"type": "control_textarea",
"validation": "None",
"wysiwyg": "Disable"
},
"12": {
"cols": "648",
"entryLimit": "None-0",
"entryLimitMin": "None-0",
"labelAlign": "Auto",
"mde": "No",
"name": "suggestionsIf",
"order": "11",
"qid": "12",
"readonly": "No",
"required": "No",
"rows": "163",
"text": "Suggestions if any for further improvement:",
"type": "control_textarea",
"validation": "None",
"wysiwyg": "Disable"
},
"13": {
"allowOther": "No",
"labelAlign": "Auto",
"name": "willYou",
"options": "Yes|Maybe|No",
"order": "12",
"otherText": "Other",
"qid": "13",
"readonly": "No",
"required": "No",
"shuffle": "No",
"special": "None",
"spreadCols": "1",
"text": "Will you be willing to recommend us?",
"type": "control_checkbox"
},
"14": {
"dcolumns": "[{"type":"Radio Button","text":"Not Satisfied"},{"type":"Check Box","text":"Somewhat Satisfied"},{"type":"Drop Down","text":"Satisfied","options":"Yes|No"},{"type":"Text Box","text":"Any thoughts?"}]",
"dropdown": "Yes|No",
"emojiCount": "5",
"inputType": "Text Box",
"labelAlign": "Top",
"mcolumns": "Full Name|Address|Contact Number",
"mrows": "1|2",
"name": "pleaseGive14",
"order": "13",
"qid": "14",
"required": "No",
"reverseSliderValues": "No",
"shuffleMatrix": "No",
"text": "Please give reference of any two people whom you feel:",
"toggleText": "Yes|No",
"type": "control_matrix"
},
"15": {
"alt": "",
"headerImage": "",
"headerType": "Default",
"imageAlign": "Left",
"name": "test",
"nextButtonText": "Next",
"order": "1",
"previousButtonText": "Previous",
"qid": "15",
"showQuestionCount": "Yes",
"subHeader": "",
"text": "Test",
"textAlign": "Left",
"type": "control_head",
"verticalTextAlign": "Middle",
"width": ""
}
},
"duration": "21ms",
"limit-left": 865
}
We need to find how how many of the numbers may be listed, so there maybe 2 in one file or 50 in another file so we can look through them and get the field names. I can get the JSON and reference it:
getdetails = "https://eu-api.jotform.com/form/" + e._currentrowdatanew.jotformform + "/questions?apiKey=" + e._currentrowdatanew.jotformapi
response = http_get(getdetails)
jsontxt = response.body
p = json_parse(jsontxt)
message = p.message
if message = "success" then
'continue to get the fields
fieldtype = p.content._10.type
But we need to loop through depending on how many numbers there are and as you can see the JSON is not standard within each section, so we need to check to see if a key exists and then reference it.
Any help would be appreciated
Alan
{
"responseCode": 200,
"message": "success",
"content": {
"1": {
"headerType": "Large",
"imageAlign": "Left",
"name": "clickTo",
"nextButtonText": "Next",
"order": "2",
"previousButtonText": "Previous",
"qid": "1",
"showQuestionCount": "Yes",
"text": "Customer Details:",
"textAlign": "Left",
"type": "control_head",
"verticalTextAlign": "Middle"
},
"2": {
"buttonAlign": "Left",
"buttonStyle": "None",
"clear": "No",
"clearText": "Clear Form",
"encryptIcon": "No",
"name": "Button",
"order": "14",
"print": "No",
"printText": "Print Form",
"qid": "2",
"text": "Submit",
"type": "control_button"
},
"3": {
"labelAlign": "Auto",
"middle": "No",
"name": "fullName3",
"order": "3",
"prefix": "No",
"qid": "3",
"readonly": "No",
"required": "Yes",
"sublabels": {
"prefix": "Prefix",
"first": "First Name",
"middle": "Middle Name",
"last": "Last Name",
"suffix": "Suffix"
},
"suffix": "No",
"text": "Full Name",
"type": "control_fullname"
},
"4": {
"countryDropdownDefaultText": "Please Select",
"customCountryDropdown": "No",
"hasAutocomplete": "No",
"hasGeolocation": "No",
"labelAlign": "Auto",
"name": "address4",
"order": "4",
"qid": "4",
"required": "Yes",
"requiredInputs": "st1|state|city|zip|country",
"states": "textbox",
"subfields": "state|zip|st1|city|st2",
"sublabels": {
"cc_firstName": "First Name",
"cc_lastName": "Last Name",
"cc_number": "Credit Card Number",
"cc_ccv": "Security Code",
"cc_exp_month": "Expiration Month",
"cc_exp_year": "Expiration Year",
"addr_line1": "Street Address",
"addr_line2": "Street Address Line 2",
"city": "City",
"state": "State / Province",
"postal": "Postal / Zip Code",
"country": "Country"
},
"text": "Address",
"type": "control_address"
},
"5": {
"countryCode": "No",
"inputMask": "enable",
"inputMaskValue": "(###) ###-####",
"labelAlign": "Auto",
"name": "phoneNumber5",
"order": "5",
"qid": "5",
"readonly": "No",
"required": "Yes",
"sublabels": {
"area": "Area Code",
"phone": "Phone Number"
},
"text": "Phone Number",
"type": "control_phone"
},
"6": {
"allowCustomDomains": "No",
"confirmation": "No",
"confirmationHint": "Confirm Email",
"confirmationSublabel": "Confirm Email",
"disallowFree": "No",
"domainCheck": "No",
"hint": "ex: [email protected]",
"labelAlign": "Auto",
"name": "email6",
"order": "6",
"qid": "6",
"readonly": "No",
"required": "No",
"size": "310",
"subLabel": "[email protected]",
"text": "E-mail",
"type": "control_email",
"validation": "Email",
"verificationCode": "No"
},
"7": {
"name": "clickTo7",
"order": "7",
"qid": "7",
"text": "<hr />",
"type": "control_text"
},
"8": {
"labelAlign": "Auto",
"multipleSelections": "No",
"name": "howDid8",
"options": "Newspaper|Internet|Magazine|Other (Please specify...)",
"order": "8",
"qid": "8",
"required": "Yes",
"searchText": "Search",
"shuffle": "No",
"size": "0",
"special": "None",
"text": "How did you hear about us?",
"type": "control_dropdown",
"visibleOptions": "1",
"width": "310"
},
"9": {
"hint": " ",
"labelAlign": "Auto",
"name": "other",
"order": "9",
"qid": "9",
"readonly": "No",
"required": "Yes",
"size": "310",
"text": "Other",
"type": "control_textbox",
"validation": "None"
},
"11": {
"cols": "648",
"entryLimit": "None-0",
"entryLimitMin": "None-0",
"labelAlign": "Auto",
"mde": "No",
"name": "feedbackAbout11",
"order": "10",
"qid": "11",
"readonly": "No",
"required": "No",
"rows": "163",
"text": "Feedback about us:",
"type": "control_textarea",
"validation": "None",
"wysiwyg": "Disable"
},
"12": {
"cols": "648",
"entryLimit": "None-0",
"entryLimitMin": "None-0",
"labelAlign": "Auto",
"mde": "No",
"name": "suggestionsIf",
"order": "11",
"qid": "12",
"readonly": "No",
"required": "No",
"rows": "163",
"text": "Suggestions if any for further improvement:",
"type": "control_textarea",
"validation": "None",
"wysiwyg": "Disable"
},
"13": {
"allowOther": "No",
"labelAlign": "Auto",
"name": "willYou",
"options": "Yes|Maybe|No",
"order": "12",
"otherText": "Other",
"qid": "13",
"readonly": "No",
"required": "No",
"shuffle": "No",
"special": "None",
"spreadCols": "1",
"text": "Will you be willing to recommend us?",
"type": "control_checkbox"
},
"14": {
"dcolumns": "[{"type":"Radio Button","text":"Not Satisfied"},{"type":"Check Box","text":"Somewhat Satisfied"},{"type":"Drop Down","text":"Satisfied","options":"Yes|No"},{"type":"Text Box","text":"Any thoughts?"}]",
"dropdown": "Yes|No",
"emojiCount": "5",
"inputType": "Text Box",
"labelAlign": "Top",
"mcolumns": "Full Name|Address|Contact Number",
"mrows": "1|2",
"name": "pleaseGive14",
"order": "13",
"qid": "14",
"required": "No",
"reverseSliderValues": "No",
"shuffleMatrix": "No",
"text": "Please give reference of any two people whom you feel:",
"toggleText": "Yes|No",
"type": "control_matrix"
},
"15": {
"alt": "",
"headerImage": "",
"headerType": "Default",
"imageAlign": "Left",
"name": "test",
"nextButtonText": "Next",
"order": "1",
"previousButtonText": "Previous",
"qid": "15",
"showQuestionCount": "Yes",
"subHeader": "",
"text": "Test",
"textAlign": "Left",
"type": "control_head",
"verticalTextAlign": "Middle",
"width": ""
}
},
"duration": "21ms",
"limit-left": 865
}
We need to find how how many of the numbers may be listed, so there maybe 2 in one file or 50 in another file so we can look through them and get the field names. I can get the JSON and reference it:
getdetails = "https://eu-api.jotform.com/form/" + e._currentrowdatanew.jotformform + "/questions?apiKey=" + e._currentrowdatanew.jotformapi
response = http_get(getdetails)
jsontxt = response.body
p = json_parse(jsontxt)
message = p.message
if message = "success" then
'continue to get the fields
fieldtype = p.content._10.type
But we need to loop through depending on how many numbers there are and as you can see the JSON is not standard within each section, so we need to check to see if a key exists and then reference it.
Any help would be appreciated
Alan
Comment