Data extraction from a Json response which is strange

I am trying to extract values of "name' and "taskID" from the below given json response. looks like its a list of multiple unnamed dictionaries. I am very new to MIT app inventor. fortunately, I am learning fast. a quicck guide will help me a lot.

[
  {
    "meta": {
      "invoices": "/v2/tasks/invoices/?tasks=16",
      "labor": "/v2/tasks/labor/?tasks=16",
      "partsUsage": "/v2/parts/usage/?tasks=16",
      "instructions": "/v2/tasks/16/instructions",
      "status": "/v2/statuses/?statuses=2"
    },
    "taskID": 16,
    "name": "Part Qty Threshold Hit",
    "userID": 0,
    "teamID": 436,
    "locationID": 73,
    "template": false,
    "createdDate": 1457569392,
    "due": 1457569392,
    "description": "",
    "dateCompleted": 1457569392,
    "lastEdited": 1518826313,
    "lastEditedByUser": 0,
    "completedByUser": 341,
    "assetID": 0,
    "completedUserWage": 15,
    "priority": 0,
    "priorityID": 8,
    "downtime": 0,
    "completionNotes": null,
    "requestorName": null,
    "requestorEmail": null,
    "requestorPhone": null,
    "requestTitle": null,
    "requestField1": null,
    "requestField2": null,
    "requestField3": null,
    "requestDropdown1": null,
    "requestDropdown2": null,
    "requestDropdown3": null,
    "requestorDescription": null,
    "meta1": null,
    "meta2": null,
    "meta3": null,
    "statusID": 2,
    "type": 7,
    "status": 1
  },
  {
    "meta": {
      "invoices": "/v2/tasks/invoices/?tasks=36",
      "labor": "/v2/tasks/labor/?tasks=36",
      "partsUsage": "/v2/parts/usage/?tasks=36",
      "instructions": "/v2/tasks/36/instructions",
      "status": "/v2/statuses/?statuses=2"
    },
    "taskID": 36,
    "name": "Part Qty Threshold Hit",
    "userID": 0,
    "teamID": 436,
    "locationID": 73,
    "template": false,
    "createdDate": 1458062821,
    "due": 1458062821,
    "description": "",
    "dateCompleted": 1458062821,
    "lastEdited": 1518826313,
    "lastEditedByUser": 0,
    "completedByUser": 341,
    "assetID": 0,
    "completedUserWage": 15,
    "priority": 0,
    "priorityID": 8,
    "downtime": 0,
    "completionNotes": null,
    "requestorName": null,
    "requestorEmail": null,
    "requestorPhone": null,
    "requestTitle": null,
    "requestField1": null,
    "requestField2": null,
    "requestField3": null,
    "requestDropdown1": null,
    "requestDropdown2": null,
    "requestDropdown3": null,
    "requestorDescription": null,
    "meta1": null,
    "meta2": null,
    "meta3": null,
    "statusID": 2,
    "type": 7,
    "status": 1
  }
]

Do you know how you want to store the extracted fields? For example, these blocks will effectively create a new list of dictionaries with just the two keys you've specified assuming responseContent contains your JSON string:

1 Like

Here's a table result:




1 Like

@ABG @ewpatton Thank you for responding. Unfortunately, I am using app inventor for iOS apps and it doesnt have the "make a new list from maping each item" block. What should I do?

Thank you again for responding. Appreciated!

You can do roughly the same thing using a variable (either local or global) initialized to a list and then use the for each loop to iterate over the list, adding the new dictionary for each entry to the list.

Note that these new blocks will be in the next iOS release sometime early to mid June.

1 Like



These reusable procedures can be dragged directly into the Blocks Editor.

1 Like

Thank you for your time and such a comprehensive guide. Now, I am able to extract data from json on the headers, name and taskID. However, when I am feeding the output to listview elements, it contains (). For example, elemenet #1 (Test Task), elemenet #2 (Test Task 2) and so on. I want to get rid of these bracets. Below is the block I am using

Thank you again for helping me.

The Table is two dimensional, but the ListView expects a one dimensional list for its Elements.

Lately I am pushing YAML as a format for Elements, where each Element is a multiline text with tag:value lines in each Element.

After Selection, you can reverse the conversion with

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.