我在chicagoboss中创建了一个表名' drugs '。已使用 Mnesia。表的架构是:
id , generic_name , brand_name ,描述
该表的一条记录是:
{
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作为单行字符串返回。我怎样才能得到正确的结构?