Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

JSON Parsing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    JSON Parsing

    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

    #2
    You've had no responses. It may be because others, like myself, don't understand what you need. Can you re-explain this part:?

    Code:
    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.
    -Steve
    sigpic

    Comment


      #3
      Steve,

      He's probably (I'm assuming) talking about the individual sections which are labeled 1,2,3,4,5, etc.


      Alan,

      First, I copied and pasted the json in your post into alpha and it won't parse. Maybe something was missed or incomplete? Nonetheless the function I think you are looking for is size(). In your case p.size(). As you drill down you might need more loops within loops.

      Here is a sample. In the sample I collect all of the donut batter types into a list from some json data...

      Code:
      dim p as p
      dim batterList as c = ""
      dim jsonData as c = ""[INDENT]jsonData = <<%json%
      [
      {
      "id": "0001",
      "type": "donut",
      "name": "Cake",
      "ppu": 0.55,
      "batters":
      {
      "batter":
      [
      { "id": "1001", "type": "Regular" },
      { "id": "1002", "type": "Chocolate" },
      { "id": "1003", "type": "Blueberry" },
      { "id": "1004", "type": "Devil's Food" }
      ]
      },
      "topping":
      [
      { "id": "5001", "type": "None" },
      { "id": "5002", "type": "Glazed" },
      { "id": "5005", "type": "Sugar" },
      { "id": "5007", "type": "Powdered Sugar" },
      { "id": "5006", "type": "Chocolate with Sprinkles" },
      { "id": "5003", "type": "Chocolate" },
      { "id": "5004", "type": "Maple" }
      ]
      },
      {
      "id": "0002",
      "type": "donut",
      "name": "Raised",
      "ppu": 0.55,
      "batters":
      {
      "batter":
      [
      { "id": "1001", "type": "Regular" }
      ]
      },
      "topping":
      [
      { "id": "5001", "type": "None" },
      { "id": "5002", "type": "Glazed" },
      { "id": "5005", "type": "Sugar" },
      { "id": "5003", "type": "Chocolate" },
      { "id": "5004", "type": "Maple" }
      ]
      },
      {
      "id": "0003",
      "type": "donut",
      "name": "Old Fashioned",
      "ppu": 0.55,
      "batters":
      {
      "batter":
      [
      { "id": "1001", "type": "Regular" },
      { "id": "1002", "type": "Chocolate" }
      ]
      },
      "topping":
      [
      { "id": "5001", "type": "None" },
      { "id": "5002", "type": "Glazed" },
      { "id": "5003", "type": "Chocolate" },
      { "id": "5004", "type": "Maple" }
      ]
      }
      ]
      %json%[/INDENT]
       
      p = json_parse(jsonData)
      
      FOR i = 1 to p.size()[INDENT]'Collect batter types[/INDENT][INDENT]FOR y = 1 to p[i].batters.batter.size()[/INDENT][INDENT=2]batterList = batterList + crlf(1) + p[i].batters.batter[y].type[/INDENT][INDENT]NEXT[/INDENT]
       
       NEXT
      On an unrelated note I really wish Alpha's forum wouldn't destroy the formatting.
      Mike Brown - Contact Me
      Programmatic Technologies, LLC
      Programmatic-Technologies.com
      Independent Developer & Consultant​​

      Comment

      Working...
      X