Json Array Add
Is a keyword used to add an element to an array in a specific Json object
Platform
Web, iOS, Android, Windows, JavaSwing, Window, API, JDBC, SSH, FTP
Properties
| Properties | Data Source | Recommended |
|---|---|---|
| Json: is the json object that is interacted with in the keyword Usually the result returned by the keywords Read Json File, Read Json String... | The default system is Variable | Json |
| fieldname: the name of the array to add the json element | The default system is Variable | String |
| value: is the value of the element to add to the array in Json | Value: value does not change during testing Variable (commonly used): is a parameter when performing data driven testing Parameter: used when the data passed into the test script changes according to the environment (Environment parameter), device (Device parameter), version (Version parameter), agent (Agent parameter) | The default system is String |
Use case
Use when you need to add an element to an array in a specific Json
Example
Json:
{
"user": [
"tester01",
"tester02"
],
"id": "5606163a-4bc5-454b-8a29-1530ddc8d8be",
"code_integer": 37684,
"code_long": 2.423235879789781e+22,
"code_double": 34854.99774,
"value": {
"name": "host",
"status": "false"
}
}
get field name = user,
value: tester_3
return result:
Json:
{
"user": [
"tester01",
"tester02",
"tester_003"
],
"id": "5606163a-4bc5-454b-8a29-1530ddc8d8be",
"code_integer": 37684,
"code_long": 2.423235879789781e+22,
"code_double": 34854.99774,
"value": {
"name": "host",
"status": "false"
}
}