Skip to content

Setting a decoder_new_doc fails #12

@MarkNijhof

Description

@MarkNijhof

Hi,

I am using elixir-mongodb which relies on this lib, now by default this returns maps with atom keys, I however would like it to return maps with string keys. So I added the following configuration:

config :bson,
    decoder_new_doc: &Bson.Decoder.elist_to_map/1

In the console I can check that it is loaded correctly:

iex(3)> Application.get_env(:bson, :decoder_new_doc, &Bson.Decoder.elist_to_atom_map/1)
&Bson.Decoder.elist_to_map/1

But when I execute the following I still get atom keys:

iex(4)> [{"a", 1}, {"b", 2}] |> Bson.encode |> Bson.decode
%{a: 1, b: 2}

From looking at the code I should be doing what I am doing, but obviously I am doing something wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions