Using JSONPath in FileMaker
For the upcoming MBS FileMaker Plugin 13.5 release, we add three new functions:
- JSON.Query - run queries against JSON with JSONPath
- JSON.Replace - replace something in JSON with JSONPath
- JSON.Search - find something in JSON with JMESPath
JSONPath queries can be used in FileMaker to work with JSON data, which is increasingly common in modern application development. FileMaker allows you to work with JSON data using the JSON functions introduced in FileMaker 16 and later versions as well as with JSON functions in our plugin. JSONPath queries can be useful in the following ways:
-
Extracting Data from JSON:
JSONPath queries can be used to extract specific data from a JSON object. For example, if you have a JSON document representing a customer's information, you can use JSONPath to extract the customer's name, email, or any other relevant data. -
Filtering JSON Arrays:
When you have a JSON array of objects, JSONPath can be used to filter the array based on certain conditions. For instance, you can filter a list of orders to only show those with a specific status or date range. -
Transforming Data:
You can use JSONPath to transform JSON data within FileMaker. For example, you can use JSONPath to modify the structure of a JSON document, adding or removing elements as needed. -
Conditional Logic:
JSONPath queries can be used in combination with FileMaker's conditional logic to create dynamic scripts and calculations. You can make decisions based on the data extracted via JSONPath. -
Integration with External APIs:
Many external APIs exchange data in JSON format. JSONPath can be used to parse and extract data from API responses, making it easier to integrate external services into your FileMaker solution. -
Data Import and Export:
JSONPath queries can be used when importing or exporting JSON data. You can specify how to map JSON data to FileMaker fields and vice versa.
Here's a basic example using the JSON Path function in FileMaker with MBS Plugin:
result = MBS("JSON.Query"; json; "$.store.book[?(@.author =~ /Evelyn.*?/)]"; 0)
This query extracts the name of the customer from a JSON object stored in the `json` field.
You may want to learn a bit about our JSON.Query function, about JSONPath and especially the implementation we use: JsonConsJsonPath.
Overall, JSONPath queries in FileMaker provide a powerful way to interact with JSON data, allowing you to work with data structures that are common in web APIs and modern data exchange formats.
Please try the new plugin soon (currently in beta testing) and let us know if you have any questions.