How to get only new values from diff and keep the original structure ?
Hello,
I would like to use this cool php library to store only overrided value of JSON config files inside a database.
I just need to have the modified value with original structure, I don't need to keep the pretty useless oldvalue.
How can I easily do that (without recursively delete all old value and move the new one) ?
Thanks for your work.
Seems like an interesting point of improvement, may be the case for more people. I think a parameter just for generating diff and returning the primitive value might be interesting (without newvalue or oldvalue). But you could use walker () - Edit json (Recursively) to get what you want too, ..., you would do on top of the returned object and add conditionals to identify the leaf, which in this case would be {oldvalue: ..., newvalue: ...}.
Current behavior
{
"new": {
"glossary/GlossDiv/GlossList/GlossEntry/Abb": "ISO 9001",
"glossary/GlossDiv/GlossList/GlossEntry/GlossDef/GlossSeeAlso/2": "JSON"
},
"removed": {
"glossary/GlossDiv/GlossList/GlossEntry/ID": "SGML"
},
"edited": {
"glossary/title": {
"oldvalue": "example glossary",
"newvalue": "example glosary"
},
"glossary/GlossDiv/GlossList/GlossEntry/GlossTerm": {
"oldvalue": "Standard Generalized Markup Language",
"newvalue": "Standard Generalized Marup Language"
}
},
"time": "0 milliseconds"
}
New behavior with a parameter
{
"new": {
"glossary/GlossDiv/GlossList/GlossEntry/Abb": "ISO 9001",
"glossary/GlossDiv/GlossList/GlossEntry/GlossDef/GlossSeeAlso/2": "JSON"
},
"removed": {
"glossary/GlossDiv/GlossList/GlossEntry/ID": "SGML"
},
"edited": {
"glossary/title": "example glosary",
"glossary/GlossDiv/GlossList/GlossEntry/GlossTerm": "Standard Generalized Marup Language"
},
"time": "0 milliseconds"
}
what do you think?
I think it's good !!! Thanks for your work ! At this time inside my code I use a "arrayRecursiveDiff" custom function.