JSON and Beyond (v2)
See the slidesSlide 1JSON: Beyond the Basics Fresh Takes, Dashboards JSON-LD, AI Integration
- Matt Navarre
- Navarre Training
Slide 2Who am I?
- Passionate trainer, Expert developer
- Certified in FM versions 7-current
- Founded 3 companies
- FBA Awards, conferences, podcasts, meetups, blog, YouTube
- Moved to Greece in 2022
Slide 3Who am I?
- Dogs & Cat
- Bicycles
- Musician
- Conductor, singer, composer
Slide 7FileMaker Champion Series
- Expert / AI Integration
- 10 hours in class - Live online
- 90 minutes 1 on 1
- Build skills - not just knowledge
- Feature-packed demo file
Slide 8Agenda
- Slides ~ 15 minutes
- Live demos ~ 25 minutes
- Q&A ~ 15 minutes
- How do YOU use JSON?
Slide 9JSON
Slide 13Douglas Crockford
Codified & Popularized JSON
Slide 14What is JSON?
- JavaScript Object Notation
- Structured text formatting
- “Light weight data interchange format”
- Human Readable
- Like XML, but it doesn’t suck™
Slide 15What is JSON?
- Hierarchical (nested structure)
- VERY FLEXIBLE
- FileMaker-y
- Since Version 16
- May 9th, 2017
- 2.902 days ago
Slide 16Why use JSON?
- Simpler
- Once you are comfortable using it
- Just like Case ( )
- And Let ( )
- Better
- Flexible
- Bulletproof
Slide 17Where to use JSON?
- Scripts
- Passing params in, processing params, sending JSON out
- ButtonBars & Layout Calculations
- Calculated Fields
- Nearly everywhere you use the Calc dialog
Slide 18When to use JSON?
- Here
- Today
- Now
- Always
Slide 19The basics… …a very quick review
Slide 20Punctuation
- FileMaker ( ) [ ] ;
- JSON { } , :
Slide 21Functions
- JSONGetElement ( )
- Two arguments: Name and Value
- JSONSetElement ( )
- Four arguments – existing json, name, value, data type
- Ability to add or modify existing data
Slide 22Functions
- JSONFormatElements ( )
- Makes it easier to read, but adds characters
- Rarely, it will break valid JSON (can’t reproduce this today though)
- JSONDelete Elements ( )
- Cleans existing JSON, including dot notation
Slide 23Functions
- JSONListKeys ( )
- Returns the names (keys) of name/value pair
- JSONListValues ( )
- Returns the values of a name/value pair
- JSONMakeArray ( )
- Newest function. Converts a List into an Array.
Slide 24String, Number, Boolean
Slide 25Basics: Passing Parameters
- I always use it – even for a single param
- Because some day, there will likely be a 2nd param
- Copy and paste code, or use shortcut
- Define $variables at top of script
- Plug for MBS
Slide 26If Data Viewer is your friend…
Slide 27… Then ChatGPT is your secret lover
Slide 28Four Use Cases
Let’s slow down…
Slide 29A JSON Field in ~Every Table Preferences & Session Data Dashboard Data JSON-LD & AI
Slide 301. A JSON Field in Most Tables
Slide 31JSON Field (stored text field)
- Main Benefits
- Write any data needed without having to change schema
- Including calculations
- Replace multiple unstirred calc fields
- Display any data
- Use a layout calculation or Button Bar
- Get any element
- Not indexed
Slide 32JSON Field – Uses
- Store metadata about the record
- Record creation details beyond date & user
- Container data, resolution, image size
- Log data
- A local list of record edits
- Record access, data quality warnings, etc.
Slide 33JSON Field – Uses
- Temporary fields
- Example: A special event where you need 5 fields for a month
- No need to pollute the schema
- Delete unused fields – with no risk
- Append data in JSON field with JSONSetElement ( )
- Delete offending fields
- Celebrate
Slide 34JSON Field – Notes
- Enter {} in the field upon record creation
- To avoid ? Error when reading
- Only use in tables where there is a high chance of use
- Or just create the field when it’s needed
- Not directly searchable
- Should have values set only by script
Slide 35Meta- data (On Create)
A little
Slide 36A lot
Slide 37Temp Data / Delete Fields
A little
Slide 38A lot
Slide 39Quick Best Practice
- Let ([
- id_company = Company::ID ;
- is_active = Company::IsActive ;
- is_active = case (is_active = 1 , “Yes” , “No”)
- ];
- JSONSetElement( “{}” ;
- [“id” ; id_company ; jsonstring] ;
- [“active” ; is_active ; jsonstring]
- ))
Slide 40JSON Field Demo
Slide 412. Preferences (global) Session Data
Slide 42Preferences & Session Data
- Main Benefits
- A single global text field in Dashboard or Globals table
- Extremely easy to access the JSON
- Replaces numerous $$variables
- Replaces numerous Global Fields in Prefs or Dashboard table
- Holds structured values, like IDs and field data for a record
- JSONDeleteElement ( ) useful to clean up a branch
Slide 433. Dashboard Data
Slide 44Dashboard Data
- Main Benefits
- Uses same Global JSON Field (as defined above)
- Write values with a script to control when data loads
- Which is much faster
- Holds structured values
- invoice.rec_count ; invoice.sold ; invoice.due
- Holds list of values in JSON Array
Slide 45Preferences, Session, & Dashboard Data Demo
Slide 464. JSON-LD For Semantic Search And Generative AI
Slide 47JSON-LD & AI
- Main Benefits
- Structured data using schema.org
- Greatly improves results for both semantic and generative AI
- Enforces good readability and clear JSON
Slide 48Sample JSON
{
"@context": "https://schema.org",
"@type": "Person",
"name": "Matt Navarre",
"job_title": "Trainer",
"company_name":"Navarre Training" }
}Slide 49Sample FM Code
- JSONSetElement ( "{}" ; // Define the JSON-LD type as Note
- ["@type" ; "Note" ; JSONString] ;
- ["data.note_text" ; Note ; JSONString] ;
- ["data.note_date" ; ISO_date (Date) ; JSONString]
- )
Slide 50Invoice Line
- JSONSetElement ( "{}" ;
- ["@type" ; "Invoice Line Item" ; JSONString] ;
- ["quantity_ordered" ; Quantity ; JSONNumber] ;
- ["item_price" ; Price ; JSONNumber] ;
- ["total_price" ; cTotal ; JSONNumber] ;
- ["category" ; IL_Product::Category ; JSONString] ;
- ["brand" ; IL_Product::Brand ; JSONString] ;
- ["model" ; IL_Product::Model ; JSONString] ;
- ["color" ; IL_Product::Color ; JSONString] ;
- ["description" ; IL_Product::Description ; JSONString]
- )
Slide 51Invoice – Uses JSONMakeArray ( )
- JSONSetElement ( "{}" ;
- ["@type" ; "Invoice" ; JSONString] ;
- ["invoice_date" ; ISO_date ( INV__Invoice::InvoiceDate ) ; JSONString] ;
- ["currency" ; "USD" ; JSONString] ;
- ["invoice_amount" ; INV__Invoice::cAmountInvoiced ; JSONNumber] ;
- ["paid_amount" ; INV__Invoice::AmountPaid ; JSONNumber] ;
- ["due_amount" ; INV__Invoice::cAmountDue ; JSONNumber] ;
- ["items" ; JSONMakeArray (List (Invoice_Lines::cJSON) ; "" ; JSONRaw ) ; JSONArray]
- )
Slide 52Company – Collect it all
- Let ([ // JSON-LD object with context and type for each record
- person_array = JSONMakeArray (List (C_Person::cJSON) ; "" ; JSONRaw) ; // Must use JSONRaw here
- invoice_array = JSONMakeArray (List (C_Invoice::cJSON) ; "" ; JSONRaw) ;
- notes_array = JSONMakeArray (List (C_Note::cJSON) ; "" ; JSONRaw) ;
- product_interest_array = JSONMakeArray (List (C_Interest::cJSON) ; "" ; JSONRaw) ;
- full_address = C__Company::Address & ", " & C__Company::CityStZip
- ];
- JSONSetElement ("{}" ;
- ["@context" ; "https://schema.org" ; JSONString] ; // Add JSON-LD context
- ["@type" ; "Organization" ; JSONString] ; // Define JSON-LD type as Organization
- ["company.name" ; C__Company::Company Name ; JSONString] ;
- ["company.total_invoiced_usd" ; Max (Total Invoiced;0) ; JSONNumber] ;
- ["company.contacts" ; person_array ; JSONArray] ;
- ["company.invoices" ; invoice_array ; JSONArray] ;
- ["company.notes" ; notes_array ; JSONArray] ;
- ["company.product_interest" ; product_interest_array ; JSONArray]))
Slide 53JSON-LD Demo
Slide 54Thank You!
- Contact information:
- www.navarre.training
- matt@navarre.training
- Claris Talk AI on YouTube and podcast platforms