06-14-2021, 09:19 PM
Can QM interact/modify a JSON file?
Assuming I have the following json file:
File: c:\test.json
Is it possible with QM to remove, add and modify and object?
I have the questions below in the code with the desired result
[/code]
Assuming I have the following json file:
File: c:\test.json
{
"version": 4,
"lastUserContextId": 1,
"identities": [{
"userContextId": 1,
"public": false,
"icon": "txt",
"color": "",
"name": "test 1",
"accessKey": ""
}, {
"userContextId": 2,
"public": false,
"icon": "txt",
"color": "",
"name": "test 2",
"accessKey": ""
}, {
"userContextId": 3,
"public": false,
"icon": "txt",
"color": "blue",
"name": "test 3"
}
]
}
Is it possible with QM to remove, add and modify and object?
I have the questions below in the code with the desired result
1. Remove whole json object 'userContextId": 3'
RESULT:
{
"version": 4,
"lastUserContextId": 1,
"identities": [{
"userContextId": 1,
"public": false,
"icon": "txt",
"color": "",
"name": "test 1",
"accessKey": ""
}, {
"userContextId": 2,
"public": false,
"icon": "txt",
"color": "",
"name": "test 2",
"accessKey": ""
}
]
}
2. Add object
"userContextId": 7,
"public": true,
"icon": "doc",
"color": "red",
"name": "test 7",
"accessKey": "123"
RESULT:
{
"version": 4,
"lastUserContextId": 1,
"identities": [{
"userContextId": 1,
"public": false,
"icon": "txt",
"color": "",
"name": "test 1",
"accessKey": ""
}, {
"userContextId": 2,
"public": false,
"icon": "txt",
"color": "",
"name": "test 2",
"accessKey": ""
}, {
"userContextId": 7,
"public": true,
"icon": "doc",
"color": "red",
"name": "test 7"
"accessKey": "123"
}
]
}
3. Modify key-value pair, of "userContextId": 1," ---> modify name from 'test 1' tot 'test 1B'
RESULT:
{
"version": 4,
"lastUserContextId": 1,
"identities": [{
"userContextId": 1,
"public": false,
"icon": "txt",
"color": "",
"name": "test B", <===============
.....
[/code]