Creating a JSON Filter

JSON is a lightweight, plain text data format. It’s become a standard that is widely used across many industries, including healthcare.

Its simple structure makes it a good example to review some key Lua and Translator concepts.

Let's set up a simple filter component that parses a JSON object and ignores data with emails not containing the "interfaceware.com" domain name.

UseFrom URL to import the component.

Copy paste the following URL:

git@bitbucket.org:interfaceware/json_tutorial.git

This component includes Sample Data to make it easier to learn how to filter messages.

Refer to Edit a Component to see how it's done if you have not done this before.

Now we are in the Developing in the Translator!

Every Translator component contains a Main.lua module with a main Functions that is called each time a message is received or on a configured poll time.

Notice we can see our sample data (Variables named Data) passed to main function by looking at the Annotation Windows.

If we click on the sample data in the annotations, we can view it using The string viewing window.

In main, parse the JSON sample data by passing Data. Create and assign the parsed data to a patient variable.

local patient = json.parse{data=Data}

JSON objects are parsed into Lua tables as dictionaries with key-value pairs. You can see this by clicking the resulting table in the Annotation Window.

Use the Create a File button to create a new filters.lua file in your Project Tree. Click Create.

Notice that when you create a new lua file, Iguana will automatically add a Require Statement to main.lua.

Now back to the https://interfaceware.atlassian.net/wiki/spaces/IXB/pages/2697691289!