# ValueTree::writeToStream with Array\<var\> fails

**URL:** <https://forum.juce.com/t/valuetree-writetostream-with-array-var-fails/30797>\
**Category:** General JUCE discussion\
**Created:** [December 10, 2018, 1:12pm UTC](https://forum.juce.com/t/valuetree-writetostream-with-array-var-fails/30797 "2018-12-10T13:12:54Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [December 10, 2018, 8:16pm UTC](https://forum.juce.com/t/valuetree-writetostream-with-array-var-fails/30797/4 "2018-12-10T20:16:58Z")

</div>

> [@ValueTree array to xml](https://forum.juce.com/t/valuetree-array-to-xml/20777/6):
>
> I use code like this to put arbitrary objects in arrays into a ValueTree. template \<typename T\> void serializeArray(ValueTree & target, const T & source) { for (auto & l : source) { auto t = l-\>getSerialized(); target.addChild(t, -1, nullptr); } } Maybe something like this adaption works for plain data types if you just want to copy data into a ValueTree in a useful way: template \<typename T\> void serializeArray(ValueTree & target, const T & source) { for (auto & l : source) { Valu…

---

_[View the full topic](https://forum.juce.com/t/valuetree-writetostream-with-array-var-fails/30797)._
