Giter Club home page Giter Club logo

filemaker-json-functions's Introduction

##WHAT

A set of recursive FileMaker custom functions that can create and read JSON.

When reading JSON, utilizes cache in $local variables to improve the speed of reading more than one value. The cache also allows for reading from JSON that is too large to be read in a single pass (due to FileMaker's max of 50,000 recursive calls).

##WHY

My previous FileMaker-JSON project was script based and used Let Notation as an intermediary format. While this method worked, it introduced the overhead of an intermediary format that may not be desirable if your intention is to create JSON to send to a web service, or parse the response from a web service. That method also relies on evaluating text as code, which introduces a security issue that may be unacceptable in certain circumstances.

##HOW TO INSTALL

Copy all functions from FileMaker-JSON-Functions.fmp12, except LogWriterMemoryCreateEntry, then paste them into your own file.

NOTE: jsonA and jsonO are included in that file, but not in this project because they are an exact copy of the functions with the same name from geistinteractive/JSONCustomFunctions.

##HOW TO USE

Refer to the Test Expression field in FileMaker-JSON-Functions.fmp12 for example code. There are examples of using similar functions here: https://www.geistinteractive.com/docs/fmqbo/working-with-json/

##WHO

I'd like to thank geist interactive for sponsoring this project. I've wanted to work in it for a while now, but with out the sponsorship, I'm not sure when I would have gotten around to it.

##STATUS

Stable (as far as I know) first release. There are currently ~180 test to verify these functions work as expected.

My goal is to match the functionality of the BaseElements backed set of custom functions with the same name available at geistinteractive/JSONCustomFunctions. This project is much slower than the BaseElements backed functions, so if the BaseElements plugin is available to you, those functions are preferred.

License

See the LICENSE file for license rights and limitations (MIT).

filemaker-json-functions's People

Contributors

dansmith65 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

filemaker-json-functions's Issues

Passing JSON parameters to FileMaker scripts?

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) output
  • much cleaner way of passing matrices of arguments

CONS

  • Is it a lot slower to work this way than to use simple key-value pairs ?
  • Custom functions required for decoding
  • dates are returned as text
  • recursion depth limits

Unicode Line Separator (U+2028) not valid

My JSON includes a U+2028 character that doesn't pass jsonValidate function, I get the following error message:

Error: control character 0xd

The hex character sequence is: e280a8

Is this correct?

Thanks for your contribution

jsonModify not encoding return chars

The following two functions should return the same key:value pairs

Although this may not be addressed with the upcoming FM v16 incorporating CF's it should be documented as many people will keep these CF's in their systems.

jsonModify ( "{}"; "returnTest" ; "first¶Second" ) & ¶ & jsonOp ( "returnTest" ; "first¶Second" )

Current result:
{"returnTest":"first¶Second"} "returnTest":"first\rSecond",

Work around:
' jsonModify ( "{}"; "returnTest" ; Substitute ( "first¶Second"; "¶" ; "\r" ) ) `

Exponential formatted values

jsonO returned the following:

jsonO (
jsonOp ( "chip_number" ; "3.56E+14")
)
//{ "chip_number":3.56E+14 }

A user imported microchip numbers in from Excel to a text field. Some of the values Excel reformatted as exponential format. These ended up in the FMGo file.

jsonO assumed this was a number and doesn't add the quotes. The PostGreSQL server was expecting a varchar(45) but rejected this because of the E+ not being within quotations.

Are you able to catch for this or can you add another parameter for jsonO to force the output type. Which might also save time when testing if 'req is too long to be a number'.

optimize ParseHex function

It shouldn't have to recurse to do it's job.

May also want to put the code right in the ParseString function since that's the only place it's called from.

jsonModify: allow positional insertion of array value?

  • insert before other values
    • negative number?
    • "unshift" (like the json method) ?
  • insert between values
    • decimal: 2.5 would insert after 2?
  • insert at end
    • I assume this would be the most common use-case
    • empty keyOrIndex value?
    • this is how the function always operates at the time of creating this issue

Equivalent to #Assign?

It would be useful if there were an equivalent function to #Assign() from the FMP Standards #Parameters module. I realize that it's possible to do something equivalent with a loop at the start of each script, but that seems like a lot of boilerplate steps.

Is this something you're considering? Or are you avoiding it in this module because dynamic variable naming requires using Evaluate() and Quote()?

don't do "next" if there is an error

I've replaced the next function with in-line code, but I think that in-line code should check if there is an error before modifying at and ch.

jsonGetKeyList ( "" ) = "?"

It should either return an empty string, or an error (I'm not sure which, yet). It seems like it's trying to process it and reaching FM's recursion limits.

~valEndPos is 1 higher than it should be

I think the ~valEndPos is 1 higher than it should be, but it may depend on how you look at it/what is the most useful. It seems to be pointing at the character after the end position at the moment.

skip one whitespace before calling whitespace function

Having a single space between elements is probably a common enough use case to account for in the code. If there is only a single whitespace character, then this enhancement would allow these functions to parse much more data before reaching the custom function recursion limit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.