Render json with array of objects

101 views Asked by At

I have code like this:

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

And I have an error:

{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}]}

Where is the problem? How to solve it?

1

There are 1 answers

0
P_A On BEST ANSWER

Probably a mistake in the last line, users must be an atom, not a string:

 {json, [{users, Users}]}.