...
Expand | |||||
---|---|---|---|---|---|
| |||||
In main, parse the JSON sample data by passing Data. Create and assign the parsed data to a patient Variable.
JSON objects are parsed into Lua tables as dictionaries with key-value pairs. You can see this clearly by clicking the resulting table in the Annotation Window. |
...
Expand | |||||
---|---|---|---|---|---|
| |||||
Notice we are brought to an empty filters.lua script in the project tree. Lets add our filtering logic: First, create a filter function Block statements and pass patient as the parameter.
Then go into main and call your filter function, passing your parsed patient JSON as the expected parameter. Notice after calling our filter function, Navigate back to the filter.lua by using clicking the purple filter in the Annotation Windows, notice there is now an annotation block we can use to add the rest of the logic. |
Expand | |||||
---|---|---|---|---|---|
| |||||
Using String:split(), we can split the email on “@“ and get the domain name. Try this code and take a look at your annotations to see the result:
Specifying the second result [2] of the split table, I can capture just the domain name. |
Expand | ||
---|---|---|
| ||
Using if statements, we can test conditions to be false and filter out data we are not interested in processing: Now lets go back to main and change the way we are calling our filter function to address the boolean values (true/false) being returned. |
...
Expand | ||
---|---|---|
| ||
By switching which Sample Data is being passed to main, we can see the results and test how our filter function works, by using the annotations. Switch Navigate to filters.lua and switch to the second sample data to see the sample message fail the condition and return false. |
...