Provide more info to the hook funcs
When you want to convert from map[string]interface{} to map[string]interface{} you don't have a lot of type information to identify a sensible type conversion.
I want to serialize some maps as JSON to disk and read them back, preserving as much of the type info as possible. This works fine when the target is typed (I can create hooks to convert from/to), not so much for map[string]interface{}. I believe this is a common enough requirement.
I can provide a patch to support this if you look positive on this (I already started a patch), but I think we need to discuss this a little first.
As I see it, we're missing some context here:
- The field name
- Whether it is a key or a value
In my quick test, testing with a map with a *big.Rat, I logged these values:
key: name: Data[myRat] , t1: string , t2: string value: myRat
value: name: Data[myRat] , t1: string , t2: interface value: 1/300
I know that Data[myRat] is a *big.Rat when I serialize it, so I can create a type mapping that I can use when I read it back, If I had a way to identify it.
I have added a suggested implementation in #123 -- that patch works good for my use case, but is maybe on the big side. I don't see a simpler way to do this.