'Problem updating an array with an object of Arrays
I am running into some issues updating and inserting an Array. As background i run a Compare by using lukascivil / TreeWalker to see what the changes are between 2 docs and then i save them to my doc.
This is the object i am trying to push into my Changes Array
Array
(
[new] => Array
(
)
[removed] => Array
(
)
[edited] => Array
(
[Address/StreetName] => Array
(
[oldvalue] => Vista Des
[newvalue] => Vista De Dons
)
[Address/StateOrProvince] => Array
(
[oldvalue] => TX
[newvalue] => CA
)
)
)
The above is $r in my code and this is how i try to push it i get from the following above $r a object of edited with multiple objects in it. Instead i want edited to be an array with multiple objects in it. What do i need to change that ?
array_push($baseRecord['Changes'], $r);
{
"new": [],
"removed": [],
"edited": {
"Address/StreetName": {
"oldvalue": "Vista Des",
"newvalue": "Vista De Dons"
},
"Address/StateOrProvince": {
"oldvalue": "TX",
"newvalue": "CA"
}
}
}
This is what it should look like and it has before moving from 7.0 to 7.4
{
"Changes" : [
{"id": "1234-123456-1234" , "EditTime" : "2022-03-17T17:43:20.855531-07:00",
"new" :[],
"removed" : [] ,
"edited" : [{
"oldvalue": "Vistaons",
"newvalue": "Vista De Dons"
},
{
"oldvalue": "(BP)",
"newvalue": "Bluff Area Properties (BP)"
}]
}
]
}
this is what is saved in JSON
{
"Changes": [
{
"new": [],
"removed": [],
"edited": {
"MLSAreaMajor": {
"oldvalue": "CB - rano Beach",
"newvalue": "CB - Capistrano Beach"
},
"Address/StreetName": {
"oldvalue": "Vista ons",
"newvalue": "Vista De Dons"
},
"Address/City": {
"oldvalue": "Daoint",
"newvalue": "Dana Point"
}
},
"id": "30633f37-0548-472a-a8ea-e409257f3637",
"changeDateTime": "2022-03-17 18:17:46"
}
],
"DocId": "Residential::a77ccc9c-82d0-4c0f-b873-055757fc171d"
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
