FileMaker Pro Tip-n-Trick — Hierarchical JSON Viewer / Editor

By Andy Persons & Doug West

eXcelisys
eXcelisys
Jan 19, 2018 · 2 min read

One of the standout new features of FileMaker Pro 16 is native support for the JSON data-interchange format. In addition to providing easy integration with a host of online services, it also provides developers with the tools to create robust hierarchical structures for use entirely within FileMaker. This hierarchical JSON viewer / editor file provides some tools for visualizing, manipulating, and leveraging JSON text.

Features

  • Automatically creates a representation of any JSON text as a hierarchical portal of records, where individual elements can be expanded and collapsed
  • Dynamically replicates changes to the hierarchical records in the JSON text, including add, edit, and delete actions
  • Highlights the corresponding JSON element when a record is selected

Applications

  • Easily visualize large JSON text, collapsing nodes to focus on just the relevant sections.
  • Manipulate JSON without needing to worry about the correct syntax
  • Convert JSON returned from a web service directly into usable Filemaker records, customizing it to your needs
  • Create and store hierarchical structures entirely in text (such as global variables), and display it as hierarchical records on the fly

How it Works

  • When JSON text is initially entered, the “JSON — Create Children” script retrieves the root keys using JSONListKeys(), loops through the result, and creates the root records.
  • When an element is eXpanded, the same script creates its child records if they don’t eXist and eXpands the hierarchy.
  • When eXpand All is clicked, a similar script “JSON — Create All Descendants” loops through every element recursively and creates all descendants.
  • Values for each record are retrieved and set using JSONGetElement().
  • To keep things streamlined, JSON key paths are used for the parent-child keys.
  • Records are marked as arrays based on the presence of a left bracket (“[“) and formatted accordingly.
  • Since JSONFormatElements() imposes a standard format, elements have a predictable number of leading and trailing lines. These are recorded in lines_leading and lines_trailing, respectively. They are then used in the Highlight Element script to calculate which part of the JSON text should be highlighted when an element record is clicked.

Enjoy!

•• ••

FileMaker

We moved to @Claris (formerly FileMaker Inc.,

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface.

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox.

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store