godbus / dbus

Native Go bindings for D-Bus
BSD 2-Clause "Simplified" License
976 stars 225 forks source link

Can't marshal a Variant value as JSON #306

Open lifubang opened 2 years ago

lifubang commented 2 years ago

As described by @kolyshkin in https://github.com/opencontainers/runc/pull/3361#issuecomment-1028584575, we can't marshal a Variant variable as a json string.

If we use json.Marshal, we will get an empty string(Not an empty string, but an empty JSON like "{}"). If we use Encode in encoding/gob, we will get an error:

Error encoding: gob: type dbus.Variant has no exported fields

Do you want to implement the json interface? Or let others who use the type Variant to implement it in their own projects?