FerretDB / wire

Apache License 2.0
2 stars 3 forks source link

Add `MarshalJSON` methods to `*Document` / `*Array` #49

Open AlekSi opened 3 days ago

AlekSi commented 3 days ago

In some cases, we need JSON representation of Document/Array, not JSON-like like we currently have. For example, extension functions accept BSON or JSON, and logging their parameters in JSON would make it easier to copy and paste them from logs to the psql console.

Let's implement encoding/json.Marshaler on *Document and *Array. Let's do the basic JSON for now, but document the fact that the exact JSON representation may change. For example, we might use Extended JSON v2 in the future.