Skip to main content
How Can We Help?
< All Topics
Print

$UpdateJSON

Updates a JSON record.

Syntax

$updatejson(source, selection-criteriareplacement)

Parameters

sourcea field, a variable, a form field or a constant containing a well formed JSON structure
selection-criteria   selection criteria to be searched within the specified source
replacementthe value to update or replace the searched string

Return Value

The character string after applying the replacement. If there are no matched criteria or if the source does not contain a well-formed JSON data structure, a $NULL value is returned.

Comments

If the selection-criteria is $null or a zero-length string, the replacement is appended to the JSON string.

If there is a selection-criteria, but the replacement is $null or a zero-length string, the entire portion belonging to the selection is deleted.

If both the selection-criteria and the replacement are not zero-length strings, the selection is found in the source and replaced by the replacement.

Example

Given the following JSON record:

out $updatejson('{"Example": ["Total": 123,"Title": "XYZ"]}',"", '"Sum": 456')

Will produce the output:

{"Example": ["Total": 123,"Title": "XYZ","Sum": 456]}
$updatejson('{"Example": ["Total": 123,"Title": "XYZ"]}',"Total", "")

returns:

{"Example": ["Title": "XYZ"]}

Replacing the keyword and its contents:

out $findjson('{"Example": ["Total": 123,"Title": "XYZ"]}',"Title", '"Sum": 456')

Outputs:

{"Example": ["Total": 123,"Sum": 456]}

See Also

$getjson

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

pt_BRPortuguese