Back to Aurora Vision Studio website

You are here: Start » Filter Reference » System » Json » Json_InsertValue_IntoArray_Object

Json_InsertValue_IntoArray_Object


Module: FoundationLite

Inserts a value of type Object into a JSON array.

Name Type Range Description
Input value inJson JsonData Input JSON data.
Input value inIndex Integer 0 - Index in the array where the value will be inserted.
Input value inReplaceExisting Bool Whether to replace the value existing at the given index.
Input value inObject JsonData Value to insert into the array.
Output value outJson JsonData Output JSON data.

Remarks

Working with JSON data

Introduction

This filter is intended to interact with data saved in JSON format.

A JSON document is composed of objects and arrays nested within each other. Each document has the main object where all other data is stored. Data in objects is stored in a key-value fashion, while data in arrays is a sequence of values. Objects are marked with braces and arrays are marked with square brackets.

The JSON filters use a custom data type that represents a single element of a JSON document. An element may represent both JSON data structures - arrays and objects, but also values stored inside them - numerics, strings or booleans.

Loading a JSON document from a file

To load a JSON document from a file, the Json_LoadFile filter is used.

During loading of a JSON document it is possible to set various format parameters and parsing options. These can also be set at a later time for each JSON data structure individually using Json_SetFormatParameters and Json_SetParseOptions filters. When nesting JSON data structures, format parameters and parsing options of the higher data structure are used for the resulting structure.

Format parameters

The format parameters allow for a more readable preview of JSON data in { {Brand} } Studio and specify the indentation of the JSON document when saving it to a file. It is recommended to disable the indentation if the preview is not used, as it introduces a small performance cost.

Accessing JSON data

After loading a JSON file all properties of arrays and objects can be accessed with Json_Access_Array and Json_Access_Object filters.

Filters from groups Json_GetValue_FromArray and Json_GetValue_FromObject can be used to access directly a value from an array or an object using its index or key.

Values of other types, such as Bool, Double, Int64, Uint64 and String can be extracted from JSON data structures of the corresponding types using the Json_GetValue_FromJsonData filters.

Creating a JSON document

The process of creating JSON documents is organized in a bottom-up approach. At the beginning, the lowest structures of the document must be created. Then, such structures can be added to a structure at a higher level in the document and that structure can be added to some yet higher structure and so on. The structure at the highest level in hierarchy must be an object.

To create an empty JSON structure Json_CreateEmpty_Array and Json_CreateEmpty_Object filters should be used.

Created JSON structures should be nested in other structures using the filters from groups Json_InsertValue_IntoArray and Json_SetValue_InObject. New structures will be added at the specified index or key.

To remove a nested structure from an array or an object, the filters from group Json_RemoveValue can be used.

Saving a JSON document to a file

To save a JSON document to a file, the Json_SaveFile filter is used.

Other

JSON data structures can be converted to and built from strings using JsonDataToString and StringToJsonData filters.

Most of Aurora Vision Studio objects can be serialized to text and stored in a JSON file. WriteToJsonData and ReadFromJsonData filters are used for that purpose.

Complexity Level

This filter is available on Basic Complexity Level.

Filter Group

This filter is member of Json_InsertValue_IntoArray filter group.

See Also

  • Json_GetValue_FromArray
  • Json_SetValue_InObject