{"id":10551,"date":"2017-05-09T06:00:31","date_gmt":"2017-05-09T13:00:31","guid":{"rendered":"https:\/\/www.seedcode.com\/?p=10551"},"modified":"2025-08-23T14:02:07","modified_gmt":"2025-08-23T21:02:07","slug":"filemaker-16-json-script-parameters","status":"publish","type":"post","link":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/","title":{"rendered":"FileMaker 16 JSON Script Parameters"},"content":{"rendered":"<p>FileMaker\u2122 16 introduces native JSON parsing which may finally give us a common language for passing multiple script parameters. This should\u00a0make sharing scripts\u00a0a lot easier. And while unpacking (reading) JSON script parameters is pretty simple, there are a few tricks to passing (writing) JSON using FileMaker&#8217;s new functions.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-large wp-image-10555\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/FM16JSON-1024x512.jpg\" alt=\"\" width=\"1024\" height=\"512\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/FM16JSON-1024x512.jpg 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/FM16JSON-300x150.jpg 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/FM16JSON-768x384.jpg 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/FM16JSON-1536x768.jpg 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/FM16JSON.jpg 2000w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<h2>Overview: better script parameters<\/h2>\n<p>The new release of FileMaker 16 includes\u00a0built-in functions for reading and writing <a href=\"http:\/\/www.json.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">JSON<\/a>: a lightweight data-interchange format widely used to pass data around between web apps. This is why it was included in FileMaker 16: to complement the enhanced cURL support, but we can use it outside of a web context\u00a0to make script parameters much\u00a0more reliable.<\/p>\n<p><em>(If you&#8217;re just looking for the example file, here it is:\u00a0<a href=\"https:\/\/archive.seedcode.com\/?smd_process_download=1&amp;download_id=10617\" target=\"_blank\" rel=\"noopener noreferrer\">JSONScriptParameters.fmp12<\/a>)<\/em><\/p>\n<p>While I\u2019m relatively new to FileMaker, I have quite a bit of experience with JSON. And, honestly, I found FileMaker\u2019s JSON implementation to be a little quirky\/unique. I would venture to say that I even disagree with how the very important JSONGetElement function is implemented. This brings me to the first, and most surprising, thing about FileMaker\u2019s JSON implementation:<\/p>\n<p>\\<s>No matter what data type you pass into your JSON parameter, the result will always be returned as text by FileMaker&#8217;s JSONGetElement function.<\/s> <strong>Note. As of 16.0.2, JSONGetElement now correctly returns Numbers and Booleans. It no longer always returns Text =)<\/strong><\/p>\n<p>Weird, but we can work with it. More on this later =)<\/p>\n<p>We\u2019re going to be exploring whether it can be beneficial to pass multiple script parameters between FileMaker scripts using the JSON as the parameter format. To review, passing single parameters between scripts is built-in to FileMaker, but once you need to pass more than one parameter, you need to come up with some kind of grammar in order to tell one parameter from another. And it would be good if your grammar understood blank parameters and didn&#8217;t freak out when your parameter contained something unexpected like a carriage return.<\/p>\n<p>Currently, in order to pass multiple parameters\u00a0from one FileMaker script to another, you can:<\/p>\n<ul>\n<li>Create global variables, which is messy as they\u00a0need to be cleaned up\u00a0each time the script runs. Plus, they don&#8217;s span files.<\/li>\n<li>Use Let() notation\u00a0like(name = value ; name2 = value2 \ud83d\ude09<\/li>\n<li>Pass a single delimited text string\u00a0with each of your\u00a0parameters in order.<\/li>\n<li>Or use a custom function, such as fmpstandards\u2019 <a href=\"https:\/\/github.com\/filemakerstandards\/fmpstandards\/tree\/master\/Functions\/%23Name-Value\" target=\"_blank\" rel=\"noopener noreferrer\">#Name-Value<\/a>.<\/li>\n<\/ul>\n<h2>Is formatting script parameters as JSON an improvement?<\/h2>\n<p><!--more-->(Spolier: Yes) But there are a few things to keep in mind and they&#8217;re mostly around writing JSON (as opposed to reading it). I&#8217;ve put together an example file showing how I like to write and read JSON in this context. You don&#8217;t need the file to follow along with this article, but there are some scripts you may want to copy from it when you&#8217;re parsing your own JSON. Download the example file\u00a0here: <a href=\"\/?smd_process_download=1&amp;download_id=10617\" target=\"_blank\" rel=\"noopener noreferrer\">JSONScriptParameters.fmp12<\/a><\/p>\n<h2>Writing JSON in FileMaker 16<\/h2>\n<p>First, let\u2019s look at the method for\u00a0writing a JSON string with multiple parameters. The following statement will create a JSON object with 3 name\/value pairs (three script parameters) in it:<\/p>\n<pre>JSONSetElement ( \"{}\";\n [\"Animal\"; SomeTable::Animal ; JSONString];\n [\"Age\"; SomeTable::Age ; JSONNumber];\n [\"Vaccinated\"; SomeTable::Vaccinated ; JSONBoolean]\n)<\/pre>\n<p>That would create a string\u00a0which looks like this:<\/p>\n<pre>{\"Age\":12,\"Animal\":\"Dog\",\"Vaccinated\":true}<\/pre>\n<p>And when that&#8217;s used as a script parameter, we can get the individual parameter we&#8217;re looking for like this:<\/p>\n<pre>JSONGetElement ( Get ( ScriptParameter )\u00a0; \"Animal\" )<\/pre>\n<p>Which returns: &#8220;Dog&#8221;<\/p>\n<p>If you want to play with JSON like this, I encourage you to put it in the data viewer so that you can change\u00a0it more easily than you can in scripts:<\/p>\n<p><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jasonsimple.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-10581 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jasonsimple-1024x642.png\" alt=\"FileMaker 16 JSON Script Parameters\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jasonsimple-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jasonsimple-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jasonsimple-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jasonsimple-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jasonsimple.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>There are a few things to note about this simple example:<\/p>\n<p><i class=\"fa fa-exclamation-circle\" style=\"font-size: 50px; float: left; padding-right: 20px; margin-top: -5px; color: #6b9aff;\"><\/i> <strong>Despite the order in which you pass your named elements, they will be in alphabetical order in your JSON.<\/strong><\/p>\n<p>and<\/p>\n<p><strong>The names are case sensitive, so JSONGetElement ( Get ( ScriptParameter )\u00a0; &#8220;animal&#8221; ) wouldn&#8217;t work in this example.<\/strong><\/p>\n<p>Notice the 3rd parameter of each object specifying the data type (JSONString, JSONNumber, etc.). You either need to specify the type of each value that you\u2019re passing, or let the JSON parser do that for you by leaving the third parameter blank (using &#8220;&#8221;) instead of something like JSONString. At this time, there\u2019s no auto-complete for these values, so you\u2019ll need to remember them.<\/p>\n<p>You can find the 7 types of JSON values in the <a href=\"https:\/\/fmhelp.filemaker.com\/help\/16\/fmp\/en\/#page\/FMP_Help\/json-functions.html\" target=\"_blank\" rel=\"noopener noreferrer\">documentation<\/a>, but here they are for reference&#8230;<\/p>\n<h4 style=\"padding-left: 60px;\">JSONString<\/h4>\n<p style=\"padding-left: 60px;\">The value included in the JSON is always included in quotes, even if you passed in a number. This is the same as applying FileMaker&#8217;s GetAsText() function to the value before passing it in.<\/p>\n<p style=\"padding-left: 60px;\">Example input: \u201ctext1\u201d<br \/>\nAdded to the JSON as: \u201ctext1\u201d<br \/>\nJSONGetElement result: \u201ctext1\u201d<\/p>\n<figure id=\"attachment_10571\" aria-describedby=\"caption-attachment-10571\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"wp-image-10571 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring-1024x648.png\" alt=\"FileMaker 16 JSONString\" width=\"1024\" height=\"648\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring-1024x648.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring-300x190.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring-768x486.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring-1536x972.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10571\" class=\"wp-caption-text\">Passing a simple string<\/figcaption><\/figure>\n<figure id=\"attachment_10612\" aria-describedby=\"caption-attachment-10612\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring2.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10612 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring2-1024x642.png\" alt=\"\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring2-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring2-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring2-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring2-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonstring2.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10612\" class=\"wp-caption-text\">Notice how returns are encoded with \\r and \\n but decoded in JSONGetElement and (unfortunately) in JSONListValues<\/figcaption><\/figure>\n<h4 style=\"padding-left: 60px;\">JSONNumber<\/h4>\n<p style=\"padding-left: 60px;\">The value included in the JSON\u00a0is included without quotes. This is the same as applying FileMaker&#8217;s GetAsNumber() function to the value before passing it in and will transform dates\u00a0to numbers as shown in the third\u00a0example.<\/p>\n<p style=\"padding-left: 60px;\">Example input:\u00a012345.67<br \/>\nAdded to the JSON as:\u00a012345.67<br \/>\nJSONGetElement result: 12345.67\u00a0(looks like a number, but remember: JSONGetElement always returns text, as shown in the second\u00a0example)<\/p>\n<p><i class=\"fa fa-exclamation-circle\" style=\"font-size: 50px; float: left; padding-right: 20px; margin-top: -5px; color: #6b9aff;\"><\/i> Note that blank values passed in using JSONNumber will be sent as 0: use JSONNull if you want to pass a blank value.<\/p>\n<figure id=\"attachment_10572\" aria-describedby=\"caption-attachment-10572\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10572 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber1-1024x642.png\" alt=\"FileMaker 16 JSONNumber\" width=\"1024\" height=\"642\" \/><\/a><figcaption id=\"caption-attachment-10572\" class=\"wp-caption-text\">Simple number parsing<\/figcaption><\/figure>\n<figure id=\"attachment_10573\" aria-describedby=\"caption-attachment-10573\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber2.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10573 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber2-1024x642.png\" alt=\"FileMaker 16 JSONNumber Script Parameters\" width=\"1024\" height=\"642\" \/><\/a><figcaption id=\"caption-attachment-10573\" class=\"wp-caption-text\">Notice how JSONGetElement returns 10 as text instead of the number 10<\/figcaption><\/figure>\n<figure id=\"attachment_10574\" aria-describedby=\"caption-attachment-10574\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber3.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10574 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber3-1024x642.png\" alt=\"JSONNumber Function\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber3-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber3-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber3-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber3-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber3.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10574\" class=\"wp-caption-text\">JSONNumber performs the same transformation on a date as GetAsNumber()<\/figcaption><\/figure>\n<figure id=\"attachment_10588\" aria-describedby=\"caption-attachment-10588\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber4.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10588 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber4-1024x642.png\" alt=\"FMP 16 JSON Script Parameters\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber4-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber4-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber4-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber4-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnumber4.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10588\" class=\"wp-caption-text\">JSONNumber turns blank values into zero<\/figcaption><\/figure>\n<h4 style=\"padding-left: 60px;\">JSONObject<\/h4>\n<p style=\"padding-left: 60px;\">Nest one JSON object as a member in another object.<\/p>\n<p style=\"padding-left: 60px;\">Example input: &#8220;{ \\&#8221;a\\&#8221; : 11 }&#8221;<br \/>\nAdded to the JSON as: \u201c{&#8220;a&#8221;:11}\u201d<br \/>\nJSONGetElement result: \u201c{&#8220;a&#8221;:11}\u201d<\/p>\n<figure id=\"attachment_10576\" aria-describedby=\"caption-attachment-10576\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonobject.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10576 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonobject-1024x642.png\" alt=\"FileMaker 16 JSONObject Script Parameters\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonobject-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonobject-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonobject-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonobject-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonobject.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10576\" class=\"wp-caption-text\">A JSON object can, itself, be a value in a JSON object<\/figcaption><\/figure>\n<h4 style=\"padding-left: 60px;\">JSONArray<\/h4>\n<p style=\"padding-left: 60px;\">A collection of delimited values tied to one name within\u00a0your JSON. Some people might\u00a0pass multiple values like this as return delimited text using JSONString, but using JSONArray\u00a0lets you address an individual member of the array\u00a0by position\u00a0instead of using GetValue()<\/p>\n<p style=\"padding-left: 60px;\">Example input: an array of objects. The objects can be any one of the 7 JSON objects. This can be used for a list of numbers \u201c[1,2,3,4,5]\u201d or text\u201c[\\\u201cstring1\\\u201d,\\\u201dstring2\\\u201d,\\\u201dstring3\\\u201d,\\\u201dstring4\\\u201d]\u201d or even a list of nested JSON strings.<br \/>\nAdded to the JSON as: \u201c[1,2,3,4,5]\u201d<br \/>\nJSONGetElement result: a text value containing an array of objects that must be extracted using JSONGetElement<\/p>\n<p style=\"padding-left: 60px;\">Example use: First, set the array to a local variable from the parameters: Set Variable [ $array : JSONGetElement ( Get(ScriptParameter) ; \u201carray\u201d] ]<\/p>\n<p style=\"padding-left: 60px;\">Next, retrieve the first value from the array and set as another local variable: Set Variable [ $array1 : JSONGetElement ( $array ; 0)]<\/p>\n<p><i class=\"fa fa-exclamation-circle\" style=\"font-size: 50px; float: left; padding-right: 20px; margin-top: -5px; color: #6b9aff;\"><\/i> Keep in mind that the way FileMaker decided to implement this, with JSON arrays and objects, the first item is at the index 0, not 1. So the first item will be item 0, then 1, 2, 3 and so on. This can be confusing for FileMaker users since with functions such as GetValue, the first item in the array is 1.<\/p>\n<figure id=\"attachment_10577\" aria-describedby=\"caption-attachment-10577\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonarray.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10577 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonarray-1024x642.png\" alt=\"FileMaker 16 JSONArray Script Parameters\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonarray-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonarray-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonarray-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonarray-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonarray.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10577\" class=\"wp-caption-text\">Addressing the second position in an array by nesting JSONGetElement<\/figcaption><\/figure>\n<figure id=\"attachment_10621\" aria-describedby=\"caption-attachment-10621\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonaray2.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-10621\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonaray2-1024x642.png\" alt=\"\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonaray2-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonaray2-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonaray2-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonaray2-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonaray2.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10621\" class=\"wp-caption-text\">Retrieving the second position of the array directly.<\/figcaption><\/figure>\n<h4 style=\"padding-left: 60px;\">JSONBoolean<\/h4>\n<p style=\"padding-left: 60px;\">True, true, &#8220;true&#8221;, 1, and any text containing a 1 are all equivalent to true. False, \u201cFalse\u201d, &#8220;True&#8221;, and 0 are equivalent to false. In reality, anything that does not match the 55\u00a0true options, such as \u201csomeText\u201d, will be evaluated as false.<\/p>\n<p style=\"padding-left: 60px;\">Example input: True<br \/>\nAdded to the JSON as: true (note the lack of quotes)<br \/>\nJSONGetElement result: 1 Interestingly, no matter how you entered the boolean, the returned value will always be 1 or 0. If you pass the parameter \u201cVaccinated\u201d as \u201ctrue\u201d and use the following if statement to read it:<\/p>\n<pre style=\"padding-left: 60px;\">JSONGetElement ( Get ( ScriptParameter) ; \"Vaccinated\" ) = \"true\"<\/pre>\n<p style=\"padding-left: 60px;\">It would evaluate to false, since the value is actually 1, not \u201ctrue\u201d.<\/p>\n<figure id=\"attachment_10584\" aria-describedby=\"caption-attachment-10584\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10584 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean1-1024x642.png\" alt=\"FileMaker 16 JSONBoolean Script Parameters\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean1-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean1-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean1-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean1-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean1.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10584\" class=\"wp-caption-text\">A simple boolean<\/figcaption><\/figure>\n<figure id=\"attachment_10585\" aria-describedby=\"caption-attachment-10585\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean2.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10585 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean2-1024x642.png\" alt=\"FM 16 JSONBoolean\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean2-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean2-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean2-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean2-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean2.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10585\" class=\"wp-caption-text\">Note that &#8220;True&#8221; in quotes is case sensitive and false in this case<\/figcaption><\/figure>\n<figure id=\"attachment_10586\" aria-describedby=\"caption-attachment-10586\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean3.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10586 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean3-1024x642.png\" alt=\"FileMaker 16 JSON Boolean\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean3-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean3-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean3-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean3-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonboolean3.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10586\" class=\"wp-caption-text\">True is true in this case<\/figcaption><\/figure>\n<h4 style=\"padding-left: 60px;\">JSONNull<\/h4>\n<p style=\"padding-left: 60px;\">This creates a named, empty member, regardless of what you pass in.<\/p>\n<p style=\"padding-left: 60px;\">Example input: \u201ctext1\u201d<br \/>\nAdded to the JSON as: \u201c\u201d<br \/>\nJSONGetElement result: \u201c\u201d<\/p>\n<figure id=\"attachment_10590\" aria-describedby=\"caption-attachment-10590\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnull1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10590 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnull1-1024x642.png\" alt=\"FileMaker 16 JSONNull Script Parameters\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnull1-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnull1-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnull1-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnull1-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnull1.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10590\" class=\"wp-caption-text\">There is nothing to see here<\/figcaption><\/figure>\n<h4 style=\"padding-left: 60px;\">JSONRaw<\/h4>\n<p style=\"padding-left: 60px;\">The same as leaving the third parameter blank (using &#8220;&#8221;). The value you pass in is run by the JSON parser and it does its best guess as to data type. This actually works pretty well for text and numbers and returns blank for blank fields. It even treats arrays like arrays if they look like arrays =). But as you&#8217;l seen in our third, fourth, and fifth example below, it can make some strange assumptions when you mix text and numbers.<\/p>\n<p style=\"padding-left: 60px;\">Example input: \u201ctext1\u201d<br \/>\nAdded to the JSON as: \u201ctext1\u201d<br \/>\nJSONGetElement result: \u201ctext1\u201d<\/p>\n<p><i class=\"fa fa-exclamation-circle\" style=\"font-size: 50px; float: left; padding-right: 20px; margin-top: -5px; color: #6b9aff;\"><\/i> JSONRaw can make some strange assumptions about values that mix text and numbers.<\/p>\n<figure id=\"attachment_10592\" aria-describedby=\"caption-attachment-10592\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10592 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw1-1024x642.png\" alt=\"FileMaker 16 JSON Null\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw1-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw1-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw1-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw1-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw1.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10592\" class=\"wp-caption-text\">JSONRaw treats this as text<\/figcaption><\/figure>\n<figure id=\"attachment_10593\" aria-describedby=\"caption-attachment-10593\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw2.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10593 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw2-1024x642.png\" alt=\"\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw2-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw2-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw2-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw2-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw2.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10593\" class=\"wp-caption-text\">JSONRaw looks for the opening and closing brackets and treats this as an array<\/figcaption><\/figure>\n<figure id=\"attachment_10594\" aria-describedby=\"caption-attachment-10594\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw3.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10594 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw3-1024x642.png\" alt=\"\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw3-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw3-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw3-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw3-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw3.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10594\" class=\"wp-caption-text\">Doesn&#8217;t quite understand dates<\/figcaption><\/figure>\n<figure id=\"attachment_10595\" aria-describedby=\"caption-attachment-10595\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw4.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10595 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw4-1024x642.png\" alt=\"\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw4-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw4-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw4-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw4-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw4.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10595\" class=\"wp-caption-text\">If numbers and text are present it seems to choose the first non-blank character to make its determination<\/figcaption><\/figure>\n<figure id=\"attachment_10610\" aria-describedby=\"caption-attachment-10610\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw5-1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10610 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw5-1-1024x642.png\" alt=\"\" width=\"1024\" height=\"642\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw5-1-1024x642.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw5-1-300x188.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw5-1-768x482.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw5-1-1536x963.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonraw5-1.png 1984w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-10610\" class=\"wp-caption-text\">Again, it guesses this is an array and discards the rest<\/figcaption><\/figure>\n<p>As you can see, those not familiar with JSON may find this structure a bit difficult to write and may dismiss JSON as an option at this point.<\/p>\n<p>One could make this easier to write by creating\u00a0FileMaker custom function to help with JSON\u00a0creation. Custom functions can be used to make common tasks easier and, in this case, they could obviate the need for remembering the third parameter by having it in the name, like &#8220;JSONSetNumber&#8221;. I find the third parameters pretty easy to remember, but regardless of how you write your JSON, the\u00a0biggest benefit to passing parameters\u00a0in JSON is that no matter which method you use to construct it, the string that is passed to the receiving script is always going to adhere to a standardized structure.<\/p>\n<h2>Reading JSON &#8211; unpacking your script parameters<\/h2>\n<p>Once we\u2019ve passed our JSON array to our script in a parameter, this is where the benefits come in.<br \/>\nFirst, you\u2019ll want your script to verify the received parameter is valid JSON:<\/p>\n<p><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/script.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10599\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/script.png\" alt=\"FileMaker 16 JSON Parsing Example\" width=\"500\" height=\"95\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/script.png 968w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/script-300x57.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/script-768x146.png 768w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>Next, you\u2019ll want to retrieve your\u00a0values\u00a0from the JSON string. You have a few options with this:<\/p>\n<p style=\"padding-left: 30px;\"><strong>1.<\/strong> Explode each of the values\u00a0in the array to a local variable using a loop or custom function.<\/p>\n<p style=\"padding-left: 30px;\"><strong>2.<\/strong> Set each parameter needed to a local variable in its own JSONGetElement line at the top of your script.<\/p>\n<p style=\"padding-left: 30px;\"><strong>3.<\/strong> Extract only the parameters you need from the script parameter\u00a0as you use them.<\/p>\n<p>With option two, possibly the most useful, you can set a single parameter from the input to a local variable using the following line:<\/p>\n<pre>Set Variable [$sc_Animal; JSONGetElement ( Get(ScriptParameter); \"Animal\")]<\/pre>\n<p>This can be repeated for each parameter\u00a0your script requires. The advantage to this method is that it lets another developer\u00a0know which variables they have to work with just by reading the top of your script. Here&#8217;s just such a script from our example file:<\/p>\n<p><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/script2.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10601 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/script2-1024x847.png\" alt=\"FileMaker 16 JSON Script Parameters Example\" width=\"1024\" height=\"847\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/script2-1024x847.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/script2-300x248.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/script2-768x635.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/script2-1536x1270.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/script2.png 1780w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Notice how lines 19-24 make it very clear which names I should use for the parameters I pass into this script. Given the parameter\u00a0names, and knowing that the script expects JSON, I have everything I need in order to pass parameters to this script. That&#8217;s the big benefit here: I no longer have to examine the script to see how it wants to receive its parameters.<\/p>\n<p>I really like writing one line for each of the requires script parameters as shown above. If, however, you want to loop through the elements and create a variable for any keys you happen to find, you&#8217;ll need to consider the catch with\u00a0JSONListValues.<\/p>\n<h2>The Catch with JSONListValues &#8211; Return Characters<\/h2>\n<p>Let&#8217;s say you pass in the values of a drop-down list field containing multiple values. This will result in a JSON formatted string like this: {&#8220;Animal&#8221;:&#8221;Cat\\rBird\\rIguana&#8221;}<\/p>\n<p>The \\r in the string represents a return character. When we use the JSONListKeys method, we get the total number of keys\/names passed in (1): Animal<\/p>\n<p>However, when we use the JSONListValues method, each one of those return characters (\\r) will add a new line to the result, so we&#8217;d have a total value count of 3:<br \/>\nCat<br \/>\nBird<br \/>\nIguana<\/p>\n<p>This means there are more values than keys\/names, so we can&#8217;t match up the key\/name index with the value index.<\/p>\n<p>In order to account for this, we can substitute the two possible return characters, \\n (char 10) and \\r (char 13), before using JSONListValues, then substitute them back when looping through each variable. While you could replace these values with any string, I find it safer and easier to use a UUID so that your chances of that string being in any of your values is extremely unlikely.<\/p>\n<p>Here&#8217;s how we accomplish this in our demo file (see lines 14-17):<\/p>\n<p><a href=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/GetValuesscript.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10614 size-large\" src=\"https:\/\/archive.seedcode.com\/wp-content\/uploads\/2017\/05\/GetValuesscript-1024x745.png\" alt=\"JSON Script Parameter Escape Returns\" width=\"1024\" height=\"745\" srcset=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/GetValuesscript-1024x745.png 1024w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/GetValuesscript-300x218.png 300w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/GetValuesscript-768x559.png 768w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/GetValuesscript-1536x1118.png 1536w, https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/GetValuesscript-2048x1490.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Then, when retrieving your value, you can substitute back in the original characters with:<br \/>\nSubstitute( Substitute ( GetValue ( $values ; $i ) ; $char13replacement ; Char(13) ) ; $char10replacement ; Char(10) )<\/p>\n<p>This can be seen in our demo file in the script &#8220;Parse JSON Parameters &#8211; Return Character Substitution&#8221;<\/p>\n<p>In this scenario, there would be more benefit had FileMaker left the escape character in the value so it could be handled later. I have a feeling that most developers would expect both the JSONGetKeys and JSONGetValues to return the same number of results at all times. The method, as-is, will probably result in a lot of headache for developers.<\/p>\n<h2>Best Practices for Numbers and Dates (wrap in GetAs&#8230; functions)<\/h2>\n<p>Because the\u00a0JSONGetElement function returns dates as text (and returned numbers as text before version 16.0.2), you&#8217;ll want to be explicit about your data types when retrieving dates and numbers from JSON script parameters.<\/p>\n<h3 style=\"padding-left: 30px;\">Numbers<\/h3>\n<p style=\"padding-left: 30px;\">Probably the most important thing to remember when using JSONGetElement is that before version 16.0.2 the result will always be a text value. Let\u2019s say you\u2019ve created the following JSON parameter:<\/p>\n<pre>$n = JSONSetElement ( \"{}\" ; \"num\" ; 10 ; JSONNumber );<\/pre>\n<p style=\"padding-left: 30px;\">Even though you\u2019ve specified the value type JSONNumber, JSONGetElement will return it as text.<\/p>\n<p style=\"padding-left: 30px;\">This means that the following would evaluate to false:<\/p>\n<pre>JSONGetElement ( $n ; \"num\" ) &gt; 2<\/pre>\n<p style=\"padding-left: 30px;\">In order to account for this, you need to tell FileMaker to cast\u00a0the result as a number with the GetAsNumber() function. The following would then evaluate to true:<\/p>\n<pre>GetAsNumber( JSONGetElement ( $n ; \"num\" ) ) &gt; 2<\/pre>\n<h3 style=\"padding-left: 30px;\">Dates<\/h3>\n<p style=\"padding-left: 30px;\">Passing dates as text can be very tricky in FileMaker, JSON aside. Different locales\u00a0use different date formats and when FileMaker converts a date to text it does so using the format in place when the file was created. This means that passing the date \u201c11\/12\/2016\u201d as text might work just fine for users in your locale, but as soon as the script is pasted into a\u00a0file\u00a0created\u00a0in another country, the text could be written as \u201c12\/11\/2016\u201d.<\/p>\n<p style=\"padding-left: 30px;\">For this reason, the best way to pass a date as a parameter would be to first convert\u00a0it into a number. Here\u2019s an example of how this can be done:<\/p>\n<pre>JSONSetElement ( \"{}\" ; \"date\" ; ExampleField::Date ; JSONNumber)<\/pre>\n<p style=\"padding-left: 30px;\">Since the result when using JSONGetElement is always returned as text, you\u2019ll also need to convert the parameter back to a number again before using the GetAsDate function:<\/p>\n<pre>Set Field [ Table::Field ; Value: GetAsDate ( GetAsNumber ( JSONGetElement ( $n ; \"date\" ) ) ) ]<\/pre>\n<h2>Conclusions<\/h2>\n<p>With all this said, do I think JSON is an effective method of passing and parsing variables between scripts in FileMaker?<\/p>\n<p>Absolutely! While it\u2019s not perfect, it would be great to see this become the new standard when developing FileMaker files.<\/p>\n<p>The biggest reason I&#8217;d like to see this as the new standard is that, no matter how the JSON string is built, it will always be in a standard JSON format in the receiving script. This makes it really easy to debug, modify, and add on to existing scripts.<\/p>\n<p>While FileMaker\u2019s JSON implementation was originally intended for integrating with 3rd party APIs, it very well could become the new standard for passing multiple script parameters between FileMaker scripts.<\/p>\n<h3>Benefits<\/h3>\n<ul>\n<li>No matter how the JSON string parameter is constructed, it will always be in a standard JSON format in the receiving script.<\/li>\n<li>JSON is hardened against content, so you don&#8217;t have to worry about including a carriage return in one of your parameters as you would if you were using returns to separate your parameters.<\/li>\n<li>JSON can also take JSON objects AS parameters. so if you need to pass all your params to a different script (as you might when using PSOS) you can just include them in one new script parameter.<\/li>\n<\/ul>\n<h3>Disadvantages &amp; Oddities<\/h3>\n<ul>\n<li>JSONGetElement always returns a text value for dates so you&#8217;ll wan to use the dates-to-numbers best practice mentioned above.<\/li>\n<li>JSON functions are not supported in runtime solutions.<\/li>\n<li>The JSONSetElement\u00a0function\u00a0can be a bit difficult to\u00a0type outside of the calc dialog.<\/li>\n<li>You either need to specify an data\u00a0type or let FileMaker detect which data\u00a0type you&#8217;re using. Letting JSON do it for you may give you some surprising results when mixing text and numbers.<\/li>\n<li>You must remember that the first item in an array is 0, not 1 as in most FileMaker functions.<\/li>\n<li>Passing an empty field as a JSONNumber will result in a JSONGetElement value of 0, not blank.<\/li>\n<\/ul>\n<p><em>This blog was really a collaborative effort; I&#8217;d like to thank Jason Young and Todd Geist for providing great ideas and feedback<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>FileMaker\u2122 16 introduces native JSON parsing which may finally give us a common language for passing multiple script parameters. This should\u00a0make sharing scripts\u00a0a lot easier. And while unpacking (reading) JSON script parameters is pretty simple, there are a few tricks to passing (writing) JSON using FileMaker&#8217;s new functions. Overview: better script parameters The new release of FileMaker 16 includes\u00a0built-in functions for reading and writing JSON: a lightweight data-interchange format widely used to pass data around between web apps. This is why it was included in FileMaker 16: to complement the enhanced cURL support, but we can use it outside of a web context\u00a0to make script parameters much\u00a0more reliable. (If you&#8217;re just looking for the example file, here it is:\u00a0JSONScriptParameters.fmp12) While I\u2019m relatively new to FileMaker, I have quite a bit of experience with JSON. And, honestly, I found FileMaker\u2019s JSON implementation to be a little quirky\/unique. I would venture to say that I even disagree with how the very important JSONGetElement function is implemented. This brings me to the first, and most surprising, thing about FileMaker\u2019s JSON implementation: \\No matter what data type you pass into your JSON parameter, the result will always be returned as text by FileMaker&#8217;s JSONGetElement function. Note. As of 16.0.2, JSONGetElement now correctly returns Numbers and Booleans. It no longer always returns Text =) Weird, but we can work with it. More on this later =) We\u2019re going to be exploring whether it can be beneficial to pass multiple script parameters between FileMaker scripts using the JSON as the parameter format. To review, passing single parameters between scripts is built-in to FileMaker, but once you need to pass more than one parameter, you need to come up with some kind of grammar in order to tell one parameter from another. And it would be good if your grammar understood blank parameters and didn&#8217;t freak out when your parameter contained something unexpected like a carriage return. Currently, in order to pass multiple parameters\u00a0from one FileMaker script to another, you can: Create global variables, which is messy as they\u00a0need to be cleaned up\u00a0each time the script runs. Plus, they don&#8217;s span files. Use Let() notation\u00a0like(name = value ; name2 = value2 \ud83d\ude09 Pass a single delimited text string\u00a0with each of your\u00a0parameters in order. Or use a custom function, such as fmpstandards\u2019 #Name-Value. Is formatting script parameters as JSON an improvement?<\/p>\n","protected":false},"author":5,"featured_media":10603,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[33],"class_list":["post-10551","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-filemaker-16"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>FileMaker 16 JSON Script Parameters - SeedCode<\/title>\n<meta name=\"description\" content=\"The new JSON parsing functions in FileMaker 16 are a great way to pass multiple script parameters. Though there are a few gotchas. Example file included.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FileMaker 16 JSON Script Parameters - SeedCode\" \/>\n<meta property=\"og:description\" content=\"The new JSON parsing functions in FileMaker 16 are a great way to pass multiple script parameters. Though there are a few gotchas. Example file included.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/\" \/>\n<meta property=\"og:site_name\" content=\"SeedCode\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/seedcoder\" \/>\n<meta property=\"article:published_time\" content=\"2017-05-09T13:00:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-23T21:02:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnfeat2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"319\" \/>\n\t<meta property=\"og:image:height\" content=\"325\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"KC Embrey\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dayback\" \/>\n<meta name=\"twitter:site\" content=\"@dayback\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"KC Embrey\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/\"},\"author\":{\"name\":\"KC Embrey\",\"@id\":\"https:\/\/seedcode.com\/#\/schema\/person\/89fd50d9241fcafac2e8fc44967d35b5\"},\"headline\":\"FileMaker 16 JSON Script Parameters\",\"datePublished\":\"2017-05-09T13:00:31+00:00\",\"dateModified\":\"2025-08-23T21:02:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/\"},\"wordCount\":2948,\"commentCount\":31,\"publisher\":{\"@id\":\"https:\/\/seedcode.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnfeat2.png\",\"keywords\":[\"FileMaker 16\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/\",\"url\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/\",\"name\":\"FileMaker 16 JSON Script Parameters - SeedCode\",\"isPartOf\":{\"@id\":\"https:\/\/seedcode.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnfeat2.png\",\"datePublished\":\"2017-05-09T13:00:31+00:00\",\"dateModified\":\"2025-08-23T21:02:07+00:00\",\"description\":\"The new JSON parsing functions in FileMaker 16 are a great way to pass multiple script parameters. Though there are a few gotchas. Example file included.\",\"breadcrumb\":{\"@id\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#primaryimage\",\"url\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnfeat2.png\",\"contentUrl\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnfeat2.png\",\"width\":319,\"height\":325},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/seedcode.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FileMaker 16 JSON Script Parameters\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/seedcode.com\/#website\",\"url\":\"https:\/\/seedcode.com\/\",\"name\":\"SeedCode\",\"description\":\"Build the Software You&#039;ve Always Wanted\",\"publisher\":{\"@id\":\"https:\/\/seedcode.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/seedcode.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/seedcode.com\/#organization\",\"name\":\"SeedCode\",\"url\":\"https:\/\/seedcode.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/seedcode.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2022\/12\/SeedCodeLogo.png\",\"contentUrl\":\"https:\/\/seedcode.com\/wp-content\/uploads\/2022\/12\/SeedCodeLogo.png\",\"width\":595,\"height\":189,\"caption\":\"SeedCode\"},\"image\":{\"@id\":\"https:\/\/seedcode.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/seedcoder\",\"https:\/\/x.com\/dayback\",\"https:\/\/www.linkedin.com\/company\/seedcode\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/seedcode.com\/#\/schema\/person\/89fd50d9241fcafac2e8fc44967d35b5\",\"name\":\"KC Embrey\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/seedcode.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3af11e9688bc5e408572c387a4f2ff4246bb7038e897bdfd5685bdf534fd5b70?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3af11e9688bc5e408572c387a4f2ff4246bb7038e897bdfd5685bdf534fd5b70?s=96&d=mm&r=g\",\"caption\":\"KC Embrey\"},\"url\":\"https:\/\/seedcode.com\/author\/kcembrey\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"FileMaker 16 JSON Script Parameters - SeedCode","description":"The new JSON parsing functions in FileMaker 16 are a great way to pass multiple script parameters. Though there are a few gotchas. Example file included.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/","og_locale":"en_US","og_type":"article","og_title":"FileMaker 16 JSON Script Parameters - SeedCode","og_description":"The new JSON parsing functions in FileMaker 16 are a great way to pass multiple script parameters. Though there are a few gotchas. Example file included.","og_url":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/","og_site_name":"SeedCode","article_publisher":"https:\/\/www.facebook.com\/seedcoder","article_published_time":"2017-05-09T13:00:31+00:00","article_modified_time":"2025-08-23T21:02:07+00:00","og_image":[{"width":319,"height":325,"url":"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnfeat2.png","type":"image\/png"}],"author":"KC Embrey","twitter_card":"summary_large_image","twitter_creator":"@dayback","twitter_site":"@dayback","twitter_misc":{"Written by":"KC Embrey","Est. reading time":"18 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#article","isPartOf":{"@id":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/"},"author":{"name":"KC Embrey","@id":"https:\/\/seedcode.com\/#\/schema\/person\/89fd50d9241fcafac2e8fc44967d35b5"},"headline":"FileMaker 16 JSON Script Parameters","datePublished":"2017-05-09T13:00:31+00:00","dateModified":"2025-08-23T21:02:07+00:00","mainEntityOfPage":{"@id":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/"},"wordCount":2948,"commentCount":31,"publisher":{"@id":"https:\/\/seedcode.com\/#organization"},"image":{"@id":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#primaryimage"},"thumbnailUrl":"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnfeat2.png","keywords":["FileMaker 16"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/","url":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/","name":"FileMaker 16 JSON Script Parameters - SeedCode","isPartOf":{"@id":"https:\/\/seedcode.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#primaryimage"},"image":{"@id":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#primaryimage"},"thumbnailUrl":"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnfeat2.png","datePublished":"2017-05-09T13:00:31+00:00","dateModified":"2025-08-23T21:02:07+00:00","description":"The new JSON parsing functions in FileMaker 16 are a great way to pass multiple script parameters. Though there are a few gotchas. Example file included.","breadcrumb":{"@id":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#primaryimage","url":"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnfeat2.png","contentUrl":"https:\/\/seedcode.com\/wp-content\/uploads\/2017\/05\/jsonnfeat2.png","width":319,"height":325},{"@type":"BreadcrumbList","@id":"https:\/\/seedcode.com\/filemaker-16-json-script-parameters\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/seedcode.com\/"},{"@type":"ListItem","position":2,"name":"FileMaker 16 JSON Script Parameters"}]},{"@type":"WebSite","@id":"https:\/\/seedcode.com\/#website","url":"https:\/\/seedcode.com\/","name":"SeedCode","description":"Build the Software You&#039;ve Always Wanted","publisher":{"@id":"https:\/\/seedcode.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/seedcode.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/seedcode.com\/#organization","name":"SeedCode","url":"https:\/\/seedcode.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/seedcode.com\/#\/schema\/logo\/image\/","url":"https:\/\/seedcode.com\/wp-content\/uploads\/2022\/12\/SeedCodeLogo.png","contentUrl":"https:\/\/seedcode.com\/wp-content\/uploads\/2022\/12\/SeedCodeLogo.png","width":595,"height":189,"caption":"SeedCode"},"image":{"@id":"https:\/\/seedcode.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/seedcoder","https:\/\/x.com\/dayback","https:\/\/www.linkedin.com\/company\/seedcode\/"]},{"@type":"Person","@id":"https:\/\/seedcode.com\/#\/schema\/person\/89fd50d9241fcafac2e8fc44967d35b5","name":"KC Embrey","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/seedcode.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3af11e9688bc5e408572c387a4f2ff4246bb7038e897bdfd5685bdf534fd5b70?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3af11e9688bc5e408572c387a4f2ff4246bb7038e897bdfd5685bdf534fd5b70?s=96&d=mm&r=g","caption":"KC Embrey"},"url":"https:\/\/seedcode.com\/author\/kcembrey\/"}]}},"_links":{"self":[{"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/posts\/10551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/comments?post=10551"}],"version-history":[{"count":3,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/posts\/10551\/revisions"}],"predecessor-version":[{"id":14644,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/posts\/10551\/revisions\/14644"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/media\/10603"}],"wp:attachment":[{"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/media?parent=10551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/categories?post=10551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seedcode.com\/wp-json\/wp\/v2\/tags?post=10551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}