MERGE function

MERGE function

Function Name Description Usage Input parameter Return value
MERGE Merges two JSON variables (objects or arrays). If same value is present in both the variables, the function removes the duplicate value. MERGE(value) JSON value to merge. A JSON object or an array.

Supported data type

The MERGE function supports the following data type:

  • JSON

Example: Merge two JSON objects

Sample data: $var1$ = {"productId": 23}

Usage: $var1$.MERGE({"productName":"radio"})

Merge the value {"productName":"radio"} with var1.

Output: {"productId": 23,"productName": "radio"}

Example: Merge two JSON arrays

Sample data: $var1$ = ["first", "second", "third"]

Usage: $var1$.MERGE([4,5])

Merge the value [4,5] with var1.

Output: ["first", "second", "third",4,5]

Recommendation

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年12月09日 UTC.