Comparison

mod_http_admin_api/mod_http_admin_api.lua @ 4350:270025e76bf8

mod_http_admin_api: Use json.encode_array() when returning an array
author Matthew Wild <mwild1@gmail.com>
date Sun, 17 Jan 2021 17:46:47 +0000
parent 4349:5ca36c36ab05
child 4351:c0b1b2a61e3c
comparison
equal deleted inserted replaced
4349:5ca36c36ab05 4350:270025e76bf8
79 table.sort(invites_list, function (a, b) 79 table.sort(invites_list, function (a, b)
80 return a.created_at < b.created_at; 80 return a.created_at < b.created_at;
81 end); 81 end);
82 82
83 event.response.headers["Content-Type"] = json_content_type; 83 event.response.headers["Content-Type"] = json_content_type;
84 return json.encode(invites_list); 84 return json.encode_array(invites_list);
85 end 85 end
86 86
87 function get_invite_by_id(event, invite_id) 87 function get_invite_by_id(event, invite_id)
88 local invite = invites.get_account_invite_info(invite_id); 88 local invite = invites.get_account_invite_info(invite_id);
89 if not invite then 89 if not invite then
135 for username in usermanager.users(module.host) do 135 for username in usermanager.users(module.host) do
136 table.insert(user_list, get_user_info(username)); 136 table.insert(user_list, get_user_info(username));
137 end 137 end
138 138
139 event.response.headers["Content-Type"] = json_content_type; 139 event.response.headers["Content-Type"] = json_content_type;
140 return json.encode(user_list); 140 return json.encode_array(user_list);
141 end 141 end
142 142
143 function get_user_by_name(event, username) 143 function get_user_by_name(event, username)
144 local user_info = get_user_info(username); 144 local user_info = get_user_info(username);
145 if not user_info then 145 if not user_info then