JSON Session
See the slidesSlide 2JSON
- What is it?
- Why does it matter?
Matt Navarre
Slide 3JSON
Slide 4Let’s Interact
- zoom.us
- 503 616 9422
Slide 5About Matt
- Passionate FileMaker trainer
- Expert FileMaker developer
- Certified in FM versions 7-2023
- Founded 3 companies
- FBA Awards, conferences, podcasts, Meetups
Hey, nice suit ^
Slide 6Free Stuff
- www.navarre.training
- SearchResutls 7
- All JSON
- Faster and easier to customize
- fmLog 3
- Coming soon…
- Training classes - Champion Track starts in January
Slide 7Quick Poll
- Do you use JSON:
- Never
- Sometimes
- Daily
Slide 8Two Part Agenda
- First: JSON Intro
- Interactive: Let’s write code
- Why I love it
- Second: Experienced JSON Users
- Show your stuff
- Show Unique Uses
- You have 90 seconds
Slide 9What is JSON?
- JavaScript Object Notation
- Structured text formatting
- “Light weight data interchange format”
- Human Readable
- Like XML, but it doesn’t suck™
Slide 10What is JSON?
- Hierarchical (nested structure)
- VERY FLEXIBLE
- FileMaker-y
- Since Version 16
- May 9th, 2017
- 2.343 days ago
Slide 11Why?
- Simpler
- Once you are comfortable using it
- Just like Case ( )
- And Let ( )
- Better
- Flexible
- Bulletproof
Like with anything in life, there are things that seem difficult at first, but then bring simplicity to your life.
Staying upright on a bike.
Playing a scale.
Creating a multi-user relational database that ends world hunger.
Slide 12Use Cases
- Passing Parameters
- Configurations & Preferences
- API Integration & Claris Connect
- Audit Logs
- Record Snapshot
Slide 13When?
- Here
- Today
- Now
Slide 14Who?
Slide 15Who?
Slide 16Who?
Slide 17Who?
Slide 18Who?
Slide 19Who?
Slide 20Who?
Douglas Crockford
He didn’t invent it, but he did popularize it
Slide 21Two Functions
- JSONGetElement ( )
- Two arguments: Name and Value
- JSONSetElement ( )
- Four arguments – two that matter most
Let’s dive into Set Element. Why start with the easy one, right?
Slide 22Data Viewer
Slide 23Data Viewer
Click here
Slide 24Set
FM Defaults
What’s important?
My preferred formatting
Slide 25Set : Single
Let’s all head to DataViewer and type this.
JSONSetElement ( "" ; "color" ; "green" ; jsonstring )
Those of you who are JSON jockeys - it’s a good time to check your email.
Slide 26Code Break
Slide 27String Number Boolean, etc.
Each line can have a type. These three are the basics
Slide 28Punctuation
- FileMaker ( ) [ ] ;
- JSON { } , :
Slide 30Code Break
Slide 31Just Kidding
We will get there though
Slide 32We were here
Why No Workie?
Copy and paste the line with the name, value, and type.
Remove the last semicolon, just as in a Case ( )
Slide 33Punctuation Marks
[ ]
Nope
Yup
Here’s how to fix. Each line needs to be encased in [ ]
Oh by the way, did you note that you can type jsonstring and it turns into JSONString?
Slide 34Real Example
Slide 35Define as Object
- JSONSetElement ( "{}"
- Defined the element as a JSON object
- JSONSetElement ( "" ;
- Let’s FileMaker try to figure it out.
Slide 36Let ( ) us do more
Did you know that you can use a LET function to define a global variable?
Well now you do. And it’s great for this class.
Let’s duplicate the line in Data Viewer, and wrap the JSON in a Let, so we can create a global variable
Slide 37Code Break
Slide 38Get
Let’s jump over to the Current tab in Data viewer
Notice that the $$variable we defined is there. This is great, because now we can learn the second, easier function: JSON GET element
Slide 39Get
It just has two arguments. Name and Value
Both can be text. Or fields. Or variables.
Slide 40Code Break
Slide 41Get
- Read All
- Read Part
- Read just one value
Slide 42Other Things you should know
- Dot Notation
- Arrays
- Format Elements
- Get Element Type
- List Keys
- List Values
- Delete Element
Slide 43Code Break
Slide 44Passing Parameters
- Passing Multiple Parameters
- Get (ScriptParameter)
- Get (ScriptResult)
Let’s integrate the simple code we just wrote. We will copy and paste the SetElement. Oh, and this is the last time you’ll need to write one from scratch - from now, just copy, paste, and edit. The beauty of DataViewer.
Slide 45More…
- Audit Logs (fmLog)
- Record Snapshot
- API Integration & Claris Connect
- Configuration & Preferences
- Dashboard data display
- SearchResults 7
Slide 46fmLog
- Free tool: fmLog
- Leverages single field
- Yes, I wrote it. But it’s free
- New version - vastly faster
- PSoS
- All JSON, all the time
- Take it apart to see the dashboard feature
Slide 47Record Snapshot
- ExecuteSQL ( “
- SELECT FieldName
- FROM FileMaker_Fields
- WHERE TableName = ?" ; "" ; "" ;
- Get ( LayoutTableName )
- )
Slide 48Record Snapshot
Slide 49API & Claris Connect
JSON is the language of the internet
Slide 50Configuration & Prefs
- Why? Endless flexibility
- Add and change preferences at will
- Nothing to change in schema
- Nothing to change in layouts
- Just Add Features
Slide 51Dashboard Data Display
- Store JSON in one field
- Use Button Bars
- The Layout Calculation Widget™
- Infinite flexibility
Slide 52SearchResults 7
- Free tool: SearchResults
- Yes, I wrote it. But it’s free
- New version - vastly faster
- PSoS
- All JSON, all the time
- Take it apart to see the dashboard feature
Slide 53Settings & Preferences
- Metadata about the database is stored in two places:
- JSON stored in one field
- One record in the SearchResults table
- Different records for different user configs
- Each with endless setting possibilities
Slide 54AI
- A Note about ChatGPT 4
- Extremely useful for learning anything new
- Use it to explain JSON functions
- Finds and corrects code mistakes
- Great source of new ideas
- Start a FileMaker conversation. It remembers.
- Still prone to hallucination
Slide 55SearchResults 7
- Search everywhere, consolidate results
- Preferences are stored in a single field
- Settings are displayed on a ButtonBar
- Found sets from multiple tables are stored in one JSON object
- And it’s free
Slide 56Part Deux
- Show Your stuff
- Share your screen on Zoom
- Talk about the problem & JSON solution
- Be brief. Or I’ll cut you.