This article is part of a series. See also…
• Thinking About JSON, part 1
• Thinking About JSON, part 2
• Thinking About JSON, part 4
This a quick followup to last month’s part 2, because today I want to to dig a little deeper into JSONSetElement and take a closer look at the first argument:

As I wrote last time…
Part of what makes JSONSetElement so powerful is that it can be used both to create new entries, and to update existing entries. Specify a valid address, and it will either create the entry if it doesn’t already exist, or update it if it does.
Let’s talk about the update aspect first, because it’s extremely straight forward. If you have existing JSON in a variable, for example $$simpleJSON, you can update it (i.e., add new elements or change existing elements) like so:
-
- JSONSetElement ( $$simpleJSON ; etc )
In other words, you use your existing JSON as the first argument.
But when it comes to creating new JSON, there are three possible first arguments to consider.
-
- JSONSetElement ( “{}” ; etc )
…instructing FileMaker to create a JSON object
- JSONSetElement ( “[]” ; etc )
…instructing FileMaker to create a JSON array
- JSONSetElement ( “” ; etc )
…trusting FileMaker to figure out which structure to create
At the risk of stating the obvious, in the first two cases we are being explicit, but in the third case we are not. (Note: If you’re unclear on the distinction between objects and arrays, this was covered in great detail in part 1.)
Continue reading “Thinking About JSON, part 3” →