Add support for automatically encoding testing.Relation data to JSON
It's already common practice to have all the field values in relation data be JSON-encoded, and this will increase more once ops supports using data classes to load/save relation data, where the default is to JSON encode/decode each field's value.
Rather than having a lot of json.dumps() in setting up testing.Relation objects, and a lot of json.loads() in asserts, it would be convenient if there was a way to have this happen transparently.
Makes sense to me. testing.Relation(..., json=True) maybe?
We're not 100% sure about the API, but something like json=True mentioned above.
Some charm unit tests use idioms like this:
tracing = Relation(
"tracing",
remote_app_data=TracingRequirerAppData(receivers=[requested_protocol]).dump(),
)
That being said, manual json.dumps() and manual plain (without json) are used in the same set of unit tests.