JSON, Level: Intermediate, Version: FM 21 or later

Traversing Arrays with Mod() and Floor()

Demo file: traverse-arrays-with-mod-and-floor.zip

Introduction

Today I want to talk about a technique that can come in handy if you need to walk a block of contiguous cells within a 2-dimensional JSON array for either reading and/or writing purposes.

[ 
   [ n, n, n, n, n, n, n, n, n, n, n, n, n, n, n ],
   [ n, n, n, n, n, n, n, n, n, n, n, n, n, n, n ],
   [ n, n, n, n, n, n, n, n, n, n, n, n, n, n, n ],
   [ n, n, n, n, n, n, n, n, n, n, n, n, n, n, n ]
]

The standard approach would be to employ a While within a While, the outer to walk the columns and the inner to walk the rows (or vice-versa). And that’s a very valid way to go about it, but I was wondering whether a 2-dimensional array of arbitrary height and width could be traversed via a single While call. Well it turns out that yes, it is possible, and we’re going to look at an approach that can accomplish this with help from the Mod() and Floor() functions.

Let’s say we have a 4 row × 15 column array, for a total of 60 cells that we want to iterate through. Since JSON uses zero based indexing, we can consider the rows to be numbered 0 – 3 and the columns to be numbered 0 – 14 like so.

Assume that our task is to fill the array with the letters A through Z, one letter per cell, starting with column [0] and populating all the rows in each column before moving on to the next column. Since there are only 26 letters in the English alphabet, after Z has been assigned start with A again, and keep iterating through the sequence until all 60 cells have been populated (and while we’re at it, let’s go with lower-case letters to make it easier on the eyes).

Conceptually, it looks like this…

…and as JSON, like this.


Continue reading “Traversing Arrays with Mod() and Floor()”

JSON, Level: Any, Version: FM 21 or later

April 2026 FM Training Livestream

Here are links to articles and resources related to my April 16 FM Training Livestream presentation: Best of FileMaker Hacks Tips, Tricks and Traps, part 5

YouTube links

Demo Files

FMH Articles

Other Resources

JSONQuery

JSON, Level: Any, Version: FM 21 or later

March 2026 FM Training Livestream

Here are links to articles and resources related to today’s FM Training Livestream presentation.

YouTube link

Demo Files

Resources

JSON, Level: Advanced, Summary List, Version: FM 21 or later

JSON Object Destringification

Today we’re going to look at an issue that can crop up in FileMaker JSON processing, and explore some approaches one might take to address this issue. Typically the issue arises with preexisting JSON coming from an API, including, but not limited to, the FM Data and OData APIs.

Demo Files

Note: minimum version to open the files is FM 21, but the examples will run significantly faster in FM 22+.

The Issue

APIs that return data as JSON are sometimes unable to recognize JSON as input, and will pass it as text rather than as an object or array. For example, both of today’s demo files include a text field containing a JSON object (the field name is “json”), and if we retrieve records via the Data API, or via the  Execute FileMaker Data API script step, the “json” field data will come back stringified (i.e., as quoted text) as per this close-up detail…

Continue reading “JSON Object Destringification”

JSON, Level: Advanced, Version: FM 21 or later

Kentuckiana FM Developers JSON Presentation

Here are links to articles and resources related to today’s KYFMP presentation on JSON custom functions and JSONQuery.

YouTube links

Presentation and Demo Files

JSON and JSON Custom Functions

Other JSON-Related Articles

JSONQuery

 

Level: Intermediate, Version: FM 21 or later

Closing Windows During Transactions

Update 2 Aug 2025: the issue documented in this article has been resolved in FM 22 (a.k.a. FM 2025).

This article documents behavior in the current shipping version of the product, i.e., FM 21 (a.k.a. FM 2024).

Demo file: transaction_test.zip (requires FM 21 or later)

This is a follow-up to last month’s article on Modal Transactional Card Windows to address a very specific question. Given that transactions are scoped to a window, does a transaction properly revert when you close the window where the transaction was initiated?

At first glance it would appear that the answer is yes, but appearances can be deceiving, and today we have a demo file from Jonathan Jeffrey that can help us understand what is actually going on, and which I am sharing with his kind permission. Continue reading “Closing Windows During Transactions”

JSON, Level: Advanced, Version: FM 21 or later

JSON Optimization in FM 21

Introduction

If you work with large JSON structures in FileMaker, you may be aware that the current shipping version of the product (FileMaker Pro 21, a.k.a. FileMaker Pro 2024) has a single-element JSON cache, which is reset whenever JSONSetElement or JSONGetElement is called, and that you can boost performance by taking this into account.

Six months ago Josh Halpern was kind enough draw my attention to this in a comment on one of my articles, and added…

“If you’re interested, I wrote a couple more points about how the JSON cache behaves here: https://the.fmsoup.org/t/performance-core-principles-10-scripting/1867/25?u=jwilling. But the gist is… only touch one json at a time.

[The above is required reading as far as I’m concerned, and has changed the way I work with JSON.]

More recently I was discussing JSON caching with Steve Senft-Herrera, and he shared a couple additional optimization ideas that had not occurred to me, and that I am definitely adding to my tool kit. (Thank you Steve.)

At any rate, today we’re going to take a look at applying all three of these ideas to speed up processing of large JSON structures within a While statement, and you can follow along in today’s demo file if you are so inclined.

Demo file: fm-21-json-optimization.zip  (requires FM 21 or later)
Continue reading “JSON Optimization in FM 21”