[[+content_image]]
C
C
cnaize2013-12-07 15:24:20
Erlang
cnaize, 2013-12-07 15:24:20

How to render json with objects from mongodb?

There is this code:

index('GET', []) ->
  Users = boss_db:find(consumer, []),
  {json, [{"users", Users}]}.

It doesn't work, it says:
{function_clause,
    [{boss_json,json_data1,
         [[{consumer,"consumer-52a3024b4346e12118000001",<<"qwe">>,
               <<"qwe">>},
           {consumer,"consumer-52a302c84346e12118000002",<<"asd">>,
               <<"asd">>},
           {consumer,"consumer-52a305264346e12118000003",<<"zxc">>,
               <<"zxc">>}],
          ["user"],
          []],
         [{file,"src/boss/boss_json.erl"},{line,23}]}

What to do with it? How to convert an array of objects so that it is rendered in json?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question