Many workflows need JSON as an attribute value instead of a file. For example, a web service may need a JSON request body, or a database field may store a JSON document.
Before FME 2026.2, these workflows used the JSONTemplater to build JSON and the JSONUpdater to add values to existing JSON. FME 2026.2 adds two transformers that do this without a template:
- The JSONObjectBuilder builds a JSON object from feature attributes. It can also insert attribute values into an existing JSON object using a pointer.
- The JSONAppender adds JSON objects to an array inside a larger JSON document.
In this article, you build a single JSON document from Vancouver public art data. In Part 1, you build one JSON object for each art installation. In Part 2, you combine the objects into one document. In Part 3, you insert metadata into the finished document.
For an overview of the JSON methods in FME 2026.2 and later, see Writing JSON in FME 2026.2 and Later. For FME 2026.1 and earlier, see Writing JSON. If you want a JSON file with one object for each feature, the JSON writer is simpler. See Writing Nested JSON with the JSON Writer.
Requirements
FME Form 2026.2 or later.
The JSONObjectBuilder and JSONAppender are not available in earlier versions.
Step-by-Step Instructions
To follow along, download PublicArt.xlsx from the Files section of this article. The workbook contains six sheets. Each sheet lists the public art installations in one Vancouver neighborhood.
At the end of this article, the workspace writes this document:
{
"dataset": "Vancouver Public Art",
"artworks": [
{
"title": "The Belonging Action",
"name": "Harbour Centre Parkade",
"location": {
"longitude": -123.110097741722,
"latitude": 49.2837806793832
}
},
...
],
"metadata": {
"source": "City of Vancouver Open Data",
"generated": "2026-11-09"
}
}Both transformers use a JSON pointer to find a location in a JSON document. A JSON pointer is a path made of keys separated by forward slashes. For example, /artworks points to the artworks key at the top level of the document. An empty pointer points to the whole document.
Part 1: Build a JSON Object for Each Feature
In this part, you use two JSONObjectBuilder transformers. The first builds a location object from the coordinates. The second builds the art installation object and places the location object inside it.
1. Open FME Workbench and Add a Microsoft Excel Reader
Open FME Workbench and start a new workspace. On the toolbar, click Add Reader. In the Add Reader dialog:
- Format: Microsoft Excel
- Dataset: PublicArt.xlsx
- Workflow Options: Single Merged Feature Type
Click OK. The Microsoft Excel reader reads all six sheets into one feature type.
2. Build the Location Object
Add a JSONObjectBuilder to the canvas and connect it to the reader feature type. Double-click the JSONObjectBuilder and set the following:
- Build Mode: Create new JSON Object
-
Member 1:
- Attribute: Longitude
- Type: float
- Key Name: longitude
-
Member 2:
- Attribute: Latitude
- Type: float
- Key Name: latitude
- Output Attribute: _location
Click OK.
Each feature now has a _location attribute, for example {"longitude":-123.103282272368, "latitude":49.2797561341325}. The float type ensures the coordinates are written as numbers, not strings. The order of the rows in the Members table sets the order of the keys.
3. Build the Art Installation Object
Add another JSONObjectBuilder and connect it to the Output port of the first JSONObjectBuilder. Double-click the new JSONObjectBuilder and set the following:
- Build Mode: Create new JSON Object
-
Member 1:
- Attribute: Title
- Type: string
- Key Name: title
-
Member 2:
- Attribute: Name
- Type: string
- Key Name: name
-
Member 3:
- Attribute: _location
- Type: json
- Key Name: location
- Write Missing Attributes as Null: Yes
- Output Attribute: _artwork
Click OK.
The JSON type tells the transformer that _location already contains JSON. The location is inserted as a nested object rather than a text string.
- Some rows in the source data have no Name value. Write Missing Attributes as Null writes "name": null for these rows, so every object has the same keys.
The JSONObjectBuilder also supports list attributes. For example, selecting outer{}.id writes an array named outer with one object for each list element. See the JSONObjectBuilder documentation for details.
4. Run the Workspace and Inspect the Objects
Enable Data Caching and run the workspace. Once the run is complete, click the green inspect button on the Output port of the second JSONObjectBuilder to open the data cache in Visual Preview.
Each feature has an _artwork attribute that contains one JSON object:
{"title":"China Gate","name":"Chinese Cultural Centre","location":{"longitude":-123.103282272368,"latitude":49.2797561341325}}Part 2: Combine the Objects Into One Document
Part 1 created one JSON object on each feature. In this part, you use the JSONAppender to add all of the objects to an array in one document. The JSONAppender has two input ports. The Document port receives the main document. The Fragment port receives the objects to add.
1. Create a Feature for the Main Document
Add a Creator to the canvas. The Creator creates a feature to hold the main document. Keep the default parameters.
2. Define the Main Document With an AttributeCreator
Add an AttributeCreator and connect it to the Creator. Double-click the AttributeCreator and set the following:
-
Output Attribute: _document
-
Value:
{"dataset": "Vancouver Public Art"}
-
Value:
Click OK.
3. Append the Objects With a JSONAppender
Add a JSONAppender to the canvas. Connect the AttributeCreator to the Document port. Connect the Output port of the second JSONObjectBuilder to the Fragment port.
Double-click the JSONAppender and set the following:
-
JSON Document:
- JSON Document Input: Attribute with JSON Document
- Attribute with JSON Document: _document
- JSON Pointer to Append Location: /artworks
-
JSON Fragment:
- JSON Fragment Input: Attribute with JSON Fragment
- Attribute with JSON Fragment: _artwork
-
Output:
- Output Attribute: _document
Click OK.
The main document does not have an artworks key yet. When only the last key in the pointer is missing, the JSONAppender creates that key as a new array and appends the objects to it. The JSONAppender waits until all features arrive, then outputs a single feature containing the full document.
Part 3: Insert Values Into the Existing Document
The JSONObjectBuilder can also add attribute values to existing JSON. This is useful when the JSON comes from another source, such as a file or a web service response. In this part, you insert a metadata object into the document from Part 2 and write the document to a file.
1. Create the Metadata Attributes
Add another AttributeCreator and connect it to the JSONAppender Output port. Double-click the AttributeCreator and set the following:
-
Output Attribute: source
-
Value:
City of Vancouver Open Data
-
Value:
-
Output Attribute: generated
-
Value:
@DateTimeFormat(@DateTimeNow(),%Y-%m-%d)
-
Value:
Click OK.
2. Insert the Metadata With a JSONObjectBuilder
Add another JSONObjectBuilder and connect it to the AttributeCreator. Double-click the JSONObjectBuilder and set the following:
- Build Mode: Insert into Existing JSON Object
- JSON Object Input: Attribute Specifying JSON Object
- Attribute with JSON Object: _document
- JSON Pointer to Insert Location: /metadata
-
Member 1:
- Attribute: source
- Type: string
-
Member 2:
- Attribute: generated
- Type: string
- Conflicting Key Strategy: Overwrite
- Output Attribute: text_line_data
Click OK.
The document does not have a metadata key yet, so the JSONObjectBuilder creates a new object and inserts the two values.
- If the document already had a metadata object with a source key, the Overwrite option would replace its value.
- The output is written to text_line_data, the attribute that the Text File writer writes in the next step.
If a document is not valid JSON, the JSONObjectBuilder sends the feature to the <Rejected> port. If the pointer cannot be resolved—for example, because it points to an array or a value that is not an object—the feature leaves through the Output port unchanged.
3. Add a Text File Writer
On the toolbar, click Add Writer. In the Add Writer dialog:
- Format: Text File
- Dataset: PublicArt_Document.json
Click OK. Connect the Output port of the third JSONObjectBuilder to the Text File writer feature type.
4. Run the Workspace and Inspect the Output
Run the workspace. Once the run is complete, open PublicArt_Document.json in a text editor. The file contains one JSON document with the dataset name, an artworks array, and a metadata object:
{
"dataset": "Vancouver Public Art",
"artworks": [
{
"title": "The Belonging Action",
"name": "Harbour Centre Parkade",
"location": {
"longitude": -123.110097741722,
"latitude": 49.2837806793832
}
},
{
"title": "Boulevard",
"name": null,
"location": {
"longitude": -123.121383,
"latitude": 49.2750459999959
}
},
...
],
"metadata": {
"source": "City of Vancouver Open Data",
"generated": "2026-11-09"
}
}The transformers write JSON on a single line. To make the file easier to read, add a JSONFormatter before the Text File writer. The output above is formatted for readability.
Additional Resources
- Writing JSON in FME 2026.2 and Later [Article]
- Writing JSON [Article]
- Writing Nested JSON with the JSON Writer [Article]
- JSONObjectBuilder [FME Documentation]
- JSONAppender [FME Documentation]
- Writing JSON with the JSONTemplater [Article]
- JavaScript Object Notation (JSON) Pointer (RFC 6901) [External]
Data Attribution
The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.