Appending values to externally saved XML or JSON

Hi there,
I want to save values outside of V4 for some longer term tracking. Therefore, I thought I would just create an XML, save some things to it and next time load that XML, append the new values to it and save it again. But somehow, I can’t wrap my head around how this could be done. When I use the “cons” and combine the loaded XElments children with my new nodes, it recreates the whole node structure inside (if that makes sense anyhow). I also had a look into JSON, but it seems to be the same problems…

Any ideas on how to do this? Or am I just missing something very obvious?

Many greetings, Lorenz

Hi @Lorenz, if I follow properly, it sounds like you are after what’s called serialization.

I would suggest creating a data type (record or class) to hold the information you want to save or reload, each of the values you want to store corresponding to a Pad (property or field) in your record/class. You can then create as many instances of these records as needed with your actual values, and serialize or deserialize them as needed.

I am pretty sure there is a help patch for serialization in the help browser somewhere.

Note: One thing to keep an eye out for is that if you at any point change the record/class properties, your old saved data will no longer be compatible with the new description and you can end up having a few headaches. Try to think ahead before making such changes.

Dear @ravazquez ,
thank you very much for your reply. I looked a bit into the serialization (here’s explanation in the reference btw: Serialization and Deserialization | vvvv gamma documentation) but was a bit scared by the custom datatypes, pads and classes :D

Luckily I figured out for what I need it is much easier just to create a .CSV file and use the “append” funcionality of the FileWriter (String) node ;-)

Greetings, Lorenz