All JUCE data-types should be easily convertible to/from var (Feature Request)

Just to name a few:

Range
Rectangle
BigInteger
Colour
Line
Point
Path
etc…

Wouldn’t it be nice, if every of these classes have a build in conversion from/to var() so you can quickly use them inside a ValueTree or JSON or Value.
These classes often including toString() methods, but Strings are not binary compatible and slower.

2 Likes

Well, it might sound like a nice idea, but for most of those it’d be ambiguous exactly how the data would be represented as a var. I’ve preferred up to now to leave it to people to write their own conversion functions for the format that’s appropriate for their own project.

Maybe you could use a virtual serialise/deserialise method on these types. That way the user can override the format to his/her specific needs.
Just add an interface called SerialisableData or similar to the types?

Can’t really do that as none of these are polymorphic. And the devil when dealing with serialisation is always in knowing which class to create when deserialising things.