Difference between revisions of "Action: JSON Parse"
Line 24: | Line 24: | ||
This data will be parsed into a dictionary variable in MacroDroid and end up populated with the data below: | This data will be parsed into a dictionary variable in MacroDroid and end up populated with the data below: | ||
− | + | <pre> | |
dictionary[firstName] = "Rajesh"<br/> | dictionary[firstName] = "Rajesh"<br/> | ||
dictionary[lastName] = "Kumar"<br/> | dictionary[lastName] = "Kumar"<br/> | ||
Line 37: | Line 37: | ||
dictionary[phoneNumbers][type] = "home"<br/> | dictionary[phoneNumbers][type] = "home"<br/> | ||
dictionary[phoneNumbers][number] = 7383627627<br/> | dictionary[phoneNumbers][number] = 7383627627<br/> | ||
− | + | </pre> | |
You can then use the values of interest from the dictionary in your macros, for example to populate a weather summary from a weather API or similar. | You can then use the values of interest from the dictionary in your macros, for example to populate a weather summary from a weather API or similar. |
Revision as of 13:24, 31 March 2022
This action enables structured data in JSON format to be parsed into a MacroDroid dictionary variable.
JSON data is a widely used format by many Web APIs to provide data in a structured/nested format. A typical example of such data is below:
{ "firstName": "Rajesh", "lastName": "Kumar", "gender": "man", "age": 24, "address": { "streetAddress": "126 Udhna", "city": "Surat", "state": "GJ", "postalCode": "394221" }, "phoneNumbers": [ { "type": "home", "number": "7383627627" } ] }
This data can be obtained from the following url: https://tools.learningcontainer.com/sample-json.json
This data will be parsed into a dictionary variable in MacroDroid and end up populated with the data below:
dictionary[firstName] = "Rajesh"<br/> dictionary[lastName] = "Kumar"<br/> dictionary[genger] = "man"<br/> dictionary[age] = 24<br/> dictionary[address] = sub-dictionary with 4 entries<br/> dictionary[address][streetAddress] = "126 Udhna"<br/> dictionary[address][city] = "Surat"<br/> dictionary[address][state] = "GJ"<br/> dictionary[address][postalCode] = "394221"<br/> dictionary[phoneNumbers] = sub-dictionary with 2 entries<br/> dictionary[phoneNumbers][type] = "home"<br/> dictionary[phoneNumbers][number] = 7383627627<br/>
You can then use the values of interest from the dictionary in your macros, for example to populate a weather summary from a weather API or similar.