vibed

How to convert associative array to key:value?

自闭症网瘾萝莉.ら 提交于 2019-12-11 10:55:39
问题 I need to convert associative array, to put them to Json, but I can't understanf how to do it. Method to!string add unnecessary slashes. int[string] name; name["Python"] = 5; Json tags = Json.emptyObject; //Json object tags["tags"] = name.to!string; writeln(tags); {"tags":"[\"Python\":1]"} I need to get: {"tags":{"Python":1}} Also I am thinking about using tuples so if there is any solution for them I would like to look at it. 回答1: to!string is the wrong approach. You don't want to convert to

How to load files to local file system with vibed?

别说谁变了你拦得住时间么 提交于 2019-12-11 00:32:59
问题 I need to send data from web-browser to local FS. For sending data I am using Vue-JS component <file-upload class="my-file-uploader" name="myFile" id="myCustomId" action="/upload" multiple>Inside Slot Text</file-upload> My server side based on vibed. But I can't find example how to save binary data to local FS. router.any("/upload", &upload); ... void upload(HTTPServerRequest req, HTTPServerResponse res) { } It's seems that I should use HTTPServerRequest.files But I can't understand how to