There is already an existing Community discussion post for this topic:
This document simply serves as a resting place for the two sample files originally associated with the above post.
Snippet from linked discussion:
"In early 2017 I became interested in the question of whether I could write a FileMaker custom function which would allow me to return ExecuteSQL results in the form of JSON. My typical use-case was grabbing data that I would then feed to code within a WebViewer..."
Reference links to two videos with some background information:
There should be two sample files attached to this Community document (the original, and a subsequent update). Originally they were attached to the discussion post, but it later became evident that it would be easier to update the files if they were instead attached to this document.
Many thanks to all of the people mentioned in the discussion post, as well as all those who participated in it.