navarre.ai

Slide archive

JSON Session

FileMaker Week Rome · 2023 · Matt Navarre · 57 slides

Slide 1
Slide 2: JSON

Slide 2JSON

  • What is it?
  • Why does it matter?

Matt Navarre

Slide 3: JSON

Slide 3JSON

Slide 4: Let’s Interact

Slide 4Let’s Interact

  • zoom.us
  • 503 616 9422
Slide 5: About Matt

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 6: Free Stuff

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 7: Quick Poll

Slide 7Quick Poll

  • Do you use JSON:
  • Never
  • Sometimes
  • Daily
Slide 8: Two Part Agenda

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 9: What is JSON?

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 10: What is JSON?

Slide 10What is JSON?

  • Hierarchical (nested structure)
  • VERY FLEXIBLE
  • FileMaker-y
  • Since Version 16
  • May 9th, 2017
  • 2.343 days ago
Slide 11: Why?

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 12: Use Cases

Slide 12Use Cases

  • Passing Parameters
  • Configurations & Preferences
  • API Integration & Claris Connect
  • Audit Logs
  • Record Snapshot
Slide 13: When?

Slide 13When?

  • Here
  • Today
  • Now
Slide 14: Who?

Slide 14Who?

Slide 15: Who?

Slide 15Who?

Slide 16: Who?

Slide 16Who?

Slide 17: Who?

Slide 17Who?

Slide 18: Who?

Slide 18Who?

Slide 19: Who?

Slide 19Who?

Slide 20: Who?

Slide 20Who?

Douglas Crockford

He didn’t invent it, but he did popularize it

Slide 21: Two Functions

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 22: Data Viewer

Slide 22Data Viewer

Slide 23: Data Viewer

Slide 23Data Viewer

Click here

Slide 24: Set

Slide 24Set

FM Defaults

What’s important?

My preferred formatting

Slide 25: Set : Single

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 26: Code Break

Slide 26Code Break

Slide 27: String Number Boolean, etc.

Slide 27String Number Boolean, etc.

Each line can have a type. These three are the basics

Slide 28: Punctuation

Slide 28Punctuation

  • FileMaker ( ) [ ] ;
  • JSON { } , :
Slide 29
Slide 30: Code Break

Slide 30Code Break

Slide 31: Just Kidding

Slide 31Just Kidding

We will get there though

Slide 32: We were here

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 33: Punctuation Marks

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 34: Real Example

Slide 34Real Example

Slide 35: Define as Object

Slide 35Define as Object

  • JSONSetElement ( "{}"
  • Defined the element as a JSON object
  • JSONSetElement ( "" ;
  • Let’s FileMaker try to figure it out.
Slide 36: Let ( ) us do more

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 37: Code Break

Slide 37Code Break

Slide 38: Get

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 39: Get

Slide 39Get

It just has two arguments. Name and Value
Both can be text. Or fields. Or variables.

Slide 40: Code Break

Slide 40Code Break

Slide 41: Get

Slide 41Get

  • Read All
  • Read Part
  • Read just one value
Slide 42: Other Things you should know

Slide 42Other Things you should know

  • Dot Notation
  • Arrays
  • Format Elements
  • Get Element Type
  • List Keys
  • List Values
  • Delete Element
Slide 43: Code Break

Slide 43Code Break

Slide 44: Passing Parameters

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 45: More…

Slide 45More…

  • Audit Logs (fmLog)
  • Record Snapshot
  • API Integration & Claris Connect
  • Configuration & Preferences
  • Dashboard data display
  • SearchResults 7
Slide 46: fmLog

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 47: Record Snapshot

Slide 47Record Snapshot

  • ExecuteSQL ( “
  • SELECT FieldName
  • FROM FileMaker_Fields
  • WHERE TableName = ?" ; "" ; "" ;
  • Get ( LayoutTableName )
  • )
Slide 48: Record Snapshot

Slide 48Record Snapshot

Slide 49: API & Claris Connect

Slide 49API & Claris Connect

JSON is the language of the internet

Slide 50: Configuration & Prefs

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 51: Dashboard Data Display

Slide 51Dashboard Data Display

  • Store JSON in one field
  • Use Button Bars
  • The Layout Calculation Widget™
  • Infinite flexibility
Slide 52: SearchResults 7

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 53: Settings & Preferences

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 54: AI

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 55: SearchResults 7

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 56: Part Deux

Slide 56Part Deux

  • Show Your stuff
  • Share your screen on Zoom
  • Talk about the problem & JSON solution
  • Be brief. Or I’ll cut you.
Slide 57