Skip to content

=JSONFIFO

The =JSONFIFO() function appends a new JSON object to an existing JSON array while optionally enforcing a maximum array length. When a maximum length is set and exceeded, the oldest entry (first in the array) is automatically removed, maintaining a First-In-First-Out (FIFO) structure.

=JSONFIFO(ExistingJsonArray; NewJsonObjectToAdd; MaximumLength)
  • ExistingJsonArray

    • A JSON array to which a new object will be added.
  • NewJsonObjectToAdd

    • A valid JSON object to append to the array.
  • MaximumLength

    • The maximum number of objects allowed in the array.

    • Use 0 to indicate no maximum limit.

  • The new JSON object is appended to the end of the array.

  • If the array size exceeds MaximumLength, the oldest object is removed.

  • If MaximumLength is 0, the array grows without restriction.

  • Ideal for rolling logs, audit trails, recent activity feeds, and history tracking.

  • Automatically manages array size without additional logic.

  • Formula function names are case sensitive and must be written in ALL CAPS.


Let’s say you’re maintaining an activity log that should only keep the 3 most recent entries.

// Starting with an existing array of 2 activities
ExistingArray = [
{"timestamp": "2025-05-30 09:00", "action": "login", "user": "john_doe"},
{"timestamp": "2025-05-30 09:15", "action": "file_upload", "user": "jane_smith"}
]
// Create new activity object
NewActivity = {"timestamp": "2025-05-30 09:30", "action": "report_generated", "user": "mike_wilson"}
// Add to array with maximum of 3 entries
=JSONFIFO(ExistingArray; NewActivity; 3)
[
{"timestamp": "2025-05-30 09:00", "action": "login", "user": "john_doe"},
{"timestamp": "2025-05-30 09:15", "action": "file_upload", "user": "jane_smith"},
{"timestamp": "2025-05-30 09:30", "action": "report_generated", "user": "mike_wilson"}
]

Adding Another Entry (Triggers FIFO Behavior)

Section titled “Adding Another Entry (Triggers FIFO Behavior)”
// Add a 4th entry - this will remove the oldest (first) entry
NewActivity2 = {"timestamp": "2025-05-30 09:45", "action": "logout", "user": "john_doe"}
=JSONFIFO([previous result]; NewActivity2; 3)
[
{"timestamp": "2025-05-30 09:15", "action": "file_upload", "user": "jane_smith"},
{"timestamp": "2025-05-30 09:30", "action": "report_generated", "user": "mike_wilson"},
{"timestamp": "2025-05-30 09:45", "action": "logout", "user": "john_doe"}
]
// Set maximum to 0 for unlimited entries
=JSONFIFO(ProductArray; {"item": "new_product", "price": 29.99}; 0)
// Keep only the most recent entry
=JSONFIFO(StatusArray; {"status": "current"}; 1)

JSONFIFO, JSON array management, FIFO queue, rolling log, activity history, JSON append, workflow logging, formula function