-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing JSON parameters to FileMaker scripts? #33
Comments
I'm not sure I agree with the pro of "cleaner get(scriptParameter) output". This project doesn't support pretty printing of the json, so it's all just one long string without whitespace. Personally, I'd say Let notation is a little easier to read than that. On the other hand, it's easy enough to use https://github.com/geistinteractive/JSONCustomFunctions with BaseElements on your development computer, which gives you access to a pretty print function, which I would say is easier to read than Let Notation. I haven't done speed tests to confirm, but I'm fairly certain that these native json functions (and probably the BaseElements backed ones, too) are slower than Let Notation. That may depend on which version of Let Notation you're using, for example #Parameters detects the data type, which is convenient, but is slower than not doing so. JSON dates and timestamps would need to be explicitly converted from a string to FileMaker's format; these functions don't do that for you. The reason for this is that JSON doesn't have a date, time, or timestamp data type, so they are stored as text in ISO format. Creating JSON requires an extra level of nesting that Let Notation doesn't have, so compare a simple object, for example:
Let notation can be created manually, if needed; JSON can't. Because of this, I use it in modules on modularfilemaker.org, where I don't want them to rely on any specific set of custom functions. Can you edit your initial comment? If not, I can edit it to add to the pros and cons list; let me know if you'd like me to. |
Thanks, Daniel... good points! "key":"value",so different than name="value";¶? I find it is with nested parameters and vectors of arguments that carriage-return delimited or let notation parameters easily become convoluted, and your module offers a nice alternative... I"ll test it more, first, but I sure find the idea promising. ( And please update the list! as I hope others will, too. ;) |
You're right; creating json manually isn't that much different than let notation... until there are characters that need to be escaped. To properly encode json in all scenarios, you would have to do everything in this function: https://github.com/dansmith65/FileMaker-JSON-Functions/blob/master/Functions/z_jsonEncodeSupport.fmfn Although, I suppose what I really meant is that you can't easily manually decode json, whereas you can manually decode let notation with a simple expression:
|
...but now we have your functions to do just that! ;) Could I add to the PROS the idea of having a parameters as data, ie. something that really stands on its own, that is understandable in any programming language? |
I forgot to mention another con: If the json being parsed is large, you may reach FileMaker's custom function recursion depth limits and the functions will return There are tests in the FileMaker-JSON-Functions.fmp12 file that demonstrate the recursion depth limit with different input json. There is no set size of the input json that will cause the functions to reach the recursion depth; it depends on the types of values in the json. |
This is meant more as a discussion opener than a, issue...
What would the PROS and CONS of passing FileMaker scripts parameters in JSON format be?
PROS
cleaner get(scriptParameter) outputCONS
The text was updated successfully, but these errors were encountered: