Bad ideas: JSON <===> tftypes.Value

I’m tinkering around with some bad idea code that invokes my framework provider’s resource and datasource CRUD methods directly. I’m not starting a provider server, and I don’t have (access to) model structs which can be used for conversion.

This plan(calling my CRUD methods) requires me to express the config, state, and plan as a tftypes.Value.

I’m starting with JSON data, so I was thrilled to discover the (deprecated) tftypes.ValueFromJSON() function. It’s exactly what I needed!

But I’ve not found an obvious way to run things in the opposite direction: turn a tftypes.Value into JSON-formatted []byte.

Before I go knock together a terrible recursive thing with knowledge of all simple, collection, and iterable in tftypes I figured I should ask…

Is there a right way to do this?