Introducing the [File.SaveObject:] ReportMagic macro

Introducing the [File.SaveObject:] Macro

We’re excited to announce the [File.SaveObject:] macro, a powerful new addition to ReportMagic that makes working with JSON data easier than ever. This macro allows you to save JObjects directly to JSON files, with intelligent handling of file conflicts and merging capabilities.

For loading JObjects from .json files, try the [File.LoadObject:] macro - documentation here.

What Does It Do?

The [File.SaveObject:] macro takes a JObject (JSON object) and saves it to a .json file in your Tenant’s folder structure. Whether you’re generating data from APIs, building complex data structures, or consolidating information from multiple sources, this macro provides a clean, reliable way to persist your JSON data.

Key Features

  • Flexible Conflict Resolution: Control what happens when a file already exists with options like error, skip, replace, or merge
  • Intelligent Merging: When merging, the macro automatically converts multiple objects into a JArray, making it perfect for accumulating data over time
  • Admin-Locked Security: Requires schedule admin locking for enhanced security
  • Clean Syntax: Works seamlessly with ReportMagic’s variable system

Example 1: Basic Usage

Here’s a simple example that creates a JObject and saves it to a file:

// Create a JObject
[Object: Value=`{ "I am Object 1" : [ true, false ] }`, =>TheObject1]

// Save it to a .json file
[File.SaveObject: FileName=Output/MyObject.json, JObject={=TheObject1}]

This creates a clean, formatted JSON file in your Output folder that you can use for reporting, data exchange, or archival purposes.

Example 2: Merging Multiple Objects

One of the most powerful features is the ability to merge multiple JObjects into a single file. This is perfect for collecting data in a loop or accumulating results over time:

// Create two JObjects
[Object: Value=`{ "I am Object 1" : "Hello" }`, =>TheObject1]
[Object: Value=`{ "I am Object 2" : 123 }`, =>TheObject2]

// Save the first to a .json file
[File.SaveObject: FileName=Output/ManyObjects.json, JObject={=TheObject1}]

// Save the second to the same .json file - results in a merge and the file contents repackaged into a JArray containing both objects
[File.SaveObject: FileName=Output/ManyObjects.json, JObject={=TheObject2}, FileConflict=Merge]

After execution, ManyObjects.json contains a JArray with both objects:

[
  { "I am Object 1" : "Hello" },
  { "I am Object 2" : 123 }
]

The merge functionality is intelligent - if the file contains a single JObject, it creates a JArray. If it already contains a JArray, it simply appends the new object to the end.

Conflict Resolution Options

The FileConflict parameter gives you fine-grained control over how the macro handles existing files:

  • error (default): throws a macro error if the file already exists
  • skip: silently skips saving if the file exists
  • skipWithWarning: skips saving and adds a warning and message to the macro
  • replace: overwrites the .json file completely, destroying previous contents
  • merge: intelligently combines objects into a JArray structure

Important Notes

  • The file extension must be .json or the macro will fail with a macro error
  • File paths are relative to your Tenant’s root folder
  • The Schedule must be admin-locked to use this macro
  • Not available in Report Studio
  • Output is automatically formatted with indentation for readability

Getting Started

The [File.SaveObject:] macro will be available in the upcoming ReportMagic version 3.28. It’s perfect for scenarios like:

  • Exporting report data for external systems
  • Building JSON data feeds
  • Accumulating results from multiple data sources
  • Generating configuration files

Ready to start working with JSON data in your reports? Try adding [File.SaveObject:] to your next schedule!


The [File.SaveObject:] macro was introduced on October 16, 2025, and is part of ReportMagic’s growing suite of file manipulation tools. Look for it in the 3.28 release