Hi everybody,
I have an issue with the JsonPackage Setvalue() function.
The help file says: "Sets the value for a key. .... If the key already exists, then overwrite the value of this key".
To me that sounds like: If you set a value of a key in an loaded JSON file, the original key will be replaced by the string you pass in this function.
Is this wite?
I have this code:
JsonPackage lnv_jpk
lnv_jpk = Create JsonPackage
lnv_jpk.ignorecase=true
long ll_rc
string ls_json1, ls_json2, ls_json3, ls_rc
ls_json1 = '{"data":{"id":"012345-001","attributes":{}}}'
ls_json2 = '{"id":174,"fname":"Anabai","lname":"Zoblotny","address":"12600 N.E. Airport Way ","city":"Denver","state":"CO","zip":"80225","phone":"3035552757","company_name":"Hats Etc."}'
ls_rc = lnv_jpk.loadstring(ls_json1)
ll_rc = lnv_jpk.setvalue( "attributes", ls_json2, true)
ls_json3 = lnv_jpk.GetJsonString()
I would expect ls_json3 with one key "Attributes". Like this:
{
"data": {
"id": "012345-001",
"attributes": {
"id": 174,
"fname": "Anabai",
"lname": "Zoblotny",
"address": "12600 N.E. Airport Way ",
"city": "Denver",
"state": "CO",
"zip": "80225",
"phone": "3035552757",
"company_name": "Hats Etc."
}
}
}
But I get:
{
"data": {
"id": "012345-001",
"attributes": {}
},
"attributes": {
"id": 174,
"fname": "Anabai",
"lname": "Zoblotny",
"address": "12600 N.E. Airport Way ",
"city": "Denver",
"state": "CO",
"zip": "80225",
"phone": "3035552757",
"company_name": "Hats Etc."
}
}
Do I miss s.th? Any suggestions?
(I can still go back and use PFC globalreplace() :-) )