chicagoBoss中的JSON编码

时间:2016-04-06 09:34:22

标签: json erlang chicagoboss

我创建了一个表名' 药物 '在chicagoboss。 Mnesia已被使用。该表的模式是:

  

id generic_name brand_name description

该表的一个记录是:

{
    drugs,
    "drugs-3",
    "Generic name",
    ["Trade Name","AnotherTradeName"],
    "This is the description of the drug"
}

以json格式打印我使用过的代码:

-module(appname_drug_controller, [Req]).
-compile(export_all).

get('GET',[])->
  ADrugs=boss_db:find("drugs-3"),
  {json, [{resposne,ADrugs}]}.

我应该得到:

{
  "resposne": {
    "id": "drugs-3",
    "generic_name": "Generic name",
    "brand_name": [
      "Trade Name",
      "AnotherTradeName"
    ],
    "description": "This is the description of the drug"
  }
}

但我得到了:

{
  "resposne": {
    "id": "drugs-3",
    "generic_name": "Generic name",
    "brand_name": "Trade NameAnotherTradeName",
    "description": "This is the description of the drug"
  }
}

因此,而不是数组 brand_name 作为单行字符串返回。我怎样才能得到正确的结构?

0 个答案:

没有答案