Exporting JSON
JSON, JSON, JSON! If you haven't gotten used to it yet, you'd better start. It's the way you communicate with the web. It's the structure that's winning. XML is too verbose, and .tab and .csv aren't always clear enough.
So, what are some of the ways you can create JSON within FileMaker? Here are just a few:
1. Create a calculated field of it.
2. Use ExecuteSQL() to return it.
3. Use Execute FileMaker Data API [ ].
4. Write a looping script.
5. Or... you can just export it.
This last method is often the most optimal for getting your data into the JSON format to meet whatever requirements you may have. You can further modify this JSON using a variety of tools to achieve the perfect result.
In this video, and the associated technique file, I provide the knowledge and code necessary to simply export your data as JSON and be done with it. No matter what you need and where you need it, you can use multiple exports from however many tables desired to end up with the needed JSON result.
Comments
Cleaning table::fieldname
Hi Matt and again thanks so much for your work!
I am learning a lot and have managed to use Json (at least) in my apps.
• For the exporting the Json with ExportRecords and to avoid having to create variables with the table::name
I clean it when I import it with this (I didn’t manage to clean it with the OpenDataFile, Read, CloseDataFile):
Let([
~keys = JSONListKeys($json; "resultset[]");
VC = ValueCount(~keys)
];
While([ i=0;~cleanedJSON = $json ]; i < VC;
[ i = i + 1;
~akey = GetValue(~keys; i);
~table = GetValue(Substitute(~akey;"::";"¶");1);
~cleanedJSON = Substitute(~cleanedJSON;~table&"::";"")
];
~cleanedJSON
)
• I have also made little changes in the $stylesheet to avoid errors with the char(13) or ¶ that are in the text to export as JSON.
I put stylesheet.xsl here in case someone is interested: http://coursington.multireflex.ovh/Fmhelp/stylesheet.xsl
Multireflex