FME Transformers: 2026.2 BETA
JSONObjectBuilder
Builds a JSON object from feature attributes, or inserts attribute values into an existing JSON object.
The transformer operates in one of two Build Modes:
- Create new JSON Object: Constructs a new JSON object on each feature.
- Insert into Existing JSON Object: Inserts attribute values into an already existing JSON object at the location specified by the JSON Pointer to Insert Location parameter.
If the key matching the final token in the pointer does not exist at the specified location, the transformer will create that key and initialize it as a new object before inserting the attribute values.
JSON Pointers
A JSON pointer is a simple mechanism to refer to values within a JSON document. It is defined by RFC 6901 and consists of a sequence of tokens separated by forward slashes (/). Each token selects an object key or array index. An empty JSON Pointer refers to the root JSON value. For example, given the JSON document:
{
"metadata": {
"title": "Value List",
"count": 2
},
"items": [
{ "id": "a", "label": "Alpha", “tags”: [2, 7] },
{ "id": "b", "label": "Bravo", “tags”: [3, 4] }
]
}
The following JSON Pointers evaluate as:
|
“” |
The entire object |
|
“/metadata” |
{ "title": "Value List", "count": 2 } |
|
“/metadata/count” |
2 |
|
“/items/0” |
{ "id": "a", "label": "Alpha", “tags”: [2, 7] } |
|
“/items/1/tags” |
[3, 4] |
The JSON pointer is used by this transformer to select the target JSON object where selected attributes will be inserted as key-value pairs.
In Insert into Existing JSON Object mode, the pointer must identify an existing object, or a location where an object can be created at the final token. Otherwise the insert location is considered unresolvable (for example, when the pointer refers to an array or non-object value) and the key value pairs will not be inserted.
For more details, see JSON Pointer to Insert Location.
See JavaScript Object Notation (JSON) Pointer at the IETF (RFC 6901).
Usage Notes
- To append values to a JSON array, use the JSONAppender.
- To assemble larger JSON documents, combine the JSONObjectBuilder with the JSONAppender.
Configuration
Input Ports
Input features containing the attributes to build into a JSON object.
In Insert into Existing JSON Object mode, input features may also include the existing JSON object when configured to read from an attribute.
Output Ports
Features with the created or updated JSON object written to the output attribute.
In Insert into Existing JSON Object mode, if the insert location is considered unresolvable, the feature will be output unchanged and the output attribute is not written.
In Insert into Existing JSON Object mode, features are sent to this port when the existing JSON object is determined to be invalid JSON. Rejected features do not halt processing, other features will continue to be evaluated.
Parameters
|
Build Mode |
Select the operating mode:
|
|
JSON Object Input |
Only applicable for Insert into Existing JSON Object mode. Selecting from the list enables that selection’s corresponding parameter:
|
|
JSON Pointer to Insert Location |
Only applicable for Insert into Existing JSON Object mode. A standard RFC 6901 JSON Pointer is used to identify the location in the JSON object where the new key value pairs will be inserted. The parameter’s default value is an empty string, which refers to the root of the object. Consider the following JSON Object: Copy
And the following selected attributes: status = “ok” notes{0} = “n0” notes{1} = “n1” If the pointer resolves to an existing object, the attributes are inserted into that object. For example, using the pointer /experiment/trials/0 produces: Copy
If all Pointer tokens exist in the document except for the last token, the transformer will create a new key from the final token, initialize it as a new JSON object, and insert the selected attributes into the newly created object. For example using the pointer /experiment/summary produces: Copy
If the pointer does not resolve to an existing object and a new object cannot be created under the final key, the insert location is considered unresolvable. This can occur when the portion of the pointer preceding the final token does not exist (e.g. /experiment/run/summary) or when the pointer refers to something other than an object, such as an array (/experiment/trails) or a non-object value (/experiment/id). In this case, the key value pairs will not be inserted, and the feature will be routed unchanged to the Output port. |
|
Attribute |
The feature attributes to include in the JSON object. Table row ordering controls the order in which keys are written. List attributes are supported and will be written as JSON arrays. When multiple list attributes share the same list path, the attributes are grouped by list index into array elements. For example, given the following attributes: outer{0}.id = 1 outer{1}.id = 2 outer{0}.inner{0}.code = A outer{0}.inner{1}.code = B outer{1}.inner{0}.code = C selecting outer{}.id and outer{}.inner{}.code produces: Copy
|
|
Type |
Specifies the type for an attribute value. The default is auto, which will write the value using the attribute’s existing type. Selecting another type will override the attribute’s existing type. For list attributes, the selected type override is applied to each list element. Available overrides are standard JSON types:
|
|
Key Name |
(Optional) The key name used when writing the attribute. If left unset, the key name defaults to the attribute name. If the key name provided for an attribute conflicts with another key name in the object, the attribute name will be used instead of the specified key name. |
|
Conflicting Key Strategy |
Only applicable for Insert into Existing JSON Object mode. Specify how to handle cases where an attribute key already exists in the target JSON object:
|
|
Write Missing Attributes as Null |
|
|
Output Attribute |
The name of the attribute to contain the built JSON object. |
Editing Transformer Parameters
Transformer parameters can be set by directly entering values, using expressions, or referencing other elements in the workspace such as attribute values or user parameters. Various editors and context menus are available to assist. To see what is available, click
beside the applicable parameter.
Defining Values
There are several ways to define a value for use in a Transformer. The simplest is to simply type in a value or string, which can include functions of various types such as attribute references, math and string functions, and workspace parameters.
Using the Text Editor
The Text Editor provides a convenient way to construct text strings (including regular expressions) from various data sources, such as attributes, parameters, and constants, where the result is used directly inside a parameter.
Using the Arithmetic Editor
The Arithmetic Editor provides a convenient way to construct math expressions from various data sources, such as attributes, parameters, and feature functions, where the result is used directly inside a parameter.
Conditional Values
Set values depending on one or more test conditions that either pass or fail.
Parameter Condition Definition Dialog
Content
Expressions and strings can include a number of functions, characters, parameters, and more.
When setting values - whether entered directly in a parameter or constructed using one of the editors - strings and expressions containing String, Math, Date/Time or FME Feature Functions will have those functions evaluated. Therefore, the names of these functions (in the form @<function_name>) should not be used as literal string values.
| These functions manipulate and format strings. | |
|
Special Characters |
A set of control characters is available in the Text Editor. |
| Math functions are available in both editors. | |
| Date/Time Functions | Date and time functions are available in the Text Editor. |
| These operators are available in the Arithmetic Editor. | |
| These return primarily feature-specific values. | |
| FME and workspace-specific parameters may be used. | |
| Creating and Modifying User Parameters | Create your own editable parameters. |
Table Tools
Transformers with table-style parameters have additional tools for populating and manipulating values.
|
Row Reordering
|
Enabled once you have clicked on a row item. Choices include:
|
|
Cut, Copy, and Paste
|
Enabled once you have clicked on a row item. Choices include:
Cut, copy, and paste may be used within a transformer, or between transformers. |
|
Filter
|
Start typing a string, and the matrix will only display rows matching those characters. Searches all columns. This only affects the display of attributes within the transformer - it does not alter which attributes are output. |
|
Import
|
Import populates the table with a set of new attributes read from a dataset. Specific application varies between transformers. |
|
Reset/Refresh
|
Generally resets the table to its initial state, and may provide additional options to remove invalid entries. Behavior varies between transformers. |
Note: Not all tools are available in all transformers.
For more information, see Transformer Parameter Menu Options.
Reference
|
Processing Behavior |
|
|
Feature Holding |
No |
| Dependencies | None |
| Aliases | |
| History |
FME Online Resources
The FME Community and Support Center Knowledge Base have a wealth of information, including active forums with 35,000+ members and thousands of articles.
Search for all results about the JSONObjectBuilder on the FME Community.
Examples may contain information licensed under the Open Government Licence – Vancouver, Open Government Licence - British Columbia, and/or Open Government Licence – Canada.