An XML Parser that converts XML into JSON on the FileMaker Pro Platform.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
As we delved into the world of REST APIs using FileMaker, we stumbled across an issue.
How do we handle XML responses?
When the REST response is a JSON object, we don't have any issue and can make use of the JSON functions introduced in FileMaker 16 to manipulate that response as we need.
However, we found out during our development of fmapi-aws-s3 that REST APIs can respond in XML.
This was an issue and with any issue, solutions are born.
We present fmapi-fm-xml2json.
A FileMaker script which when passed a valid XML string, will covert this string into a JSON object.
- FileMaker Pro
- No 3rd party plugins.
The FileMaker script makes use of the JSON Functions introduced in FileMaker 16.
This means that this script will only work with FileMaker 16+ products.
Using the script with anything less than 16 will have unexpected behaviour.
We make use of the #Name-Value custom function provided by filemakerstandards.
Please copy the following Custom Functions to your solution before copying the script:
FileMaker Pro is not the most efficient tool for text parsing. This script was designed primarily for small XML packets sent back from APIs. It wasn't designed, in mind, to convert large XML files into JSON.
However, if given enough time, this script will convert large XML files into JSON and has been optimised to the best of our ability.
Unfortunately, FileMaker can only go so far before it starts to fall over.
We've performed some benchmark tests to give you an idea of how long it takes the script to execute.
XML Size (KB) | Execution Time (ms) | Readable Time |
---|---|---|
4 | 958 | 0.9s |
8 | 1644 | 1.6s |
17 | 3430 | 3.4s |
35 | 8767 | 8.7s |
71 | 26435 | 26.4s |
142 | 87973 | 1min 27.9s |
KB was determined using FileMaker's Length ( field )
function.
As stated above this script wasn't developed with the purpose of taking large XML data and converting it to JSON.
If you do have this need, we strongly suggest using a plugin or performing the conversion outside of FileMaker and then importing the result back into FileMaker.
We have built the rules for identifying XML nodes in FileMaker using all the Text Functions available to us and from our testing it has handled all the testing XML data thrown at it.
However, there may be some fringe cases where this breaks down. If you discover such a case, please create a Bug Report and we'll see if we can correct it. Unfortunately, there may be cases that can't be solved.
- Make sure that the Custom Functions have been added to your solution.
- Copy the
fm-xml2json
script to your solution.
TODO
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Steven McGill - WhiteSpace Systems Ltd - steven@whitespacesystems.co.uk
Project Link: fm-xml2json