发送Http.MultipartRequest作为扑扑数组?

问题描述

这就是我将数据发布到服务器的方式

var request = new http.MultipartRequest("POST",uri);
request.headers.addAll(headers);
request.fields['property_id'] = property_id; //value from textcontroller
request.fields['unit_id'] = unitlist; //value from textcontroller
request.fields['tenant_name'] = tenant_name; //value from textcontroller
request.fields['additional_terms'] = addistiona_tems;//value from textcontroller
var stream = new http.ByteStream(DelegatingStream.typed(file.openRead()));
var length = await file.length();
var tenantimage = new http.multipartfile('Tenant_image',stream,length,filename: basename(file.path));
request.files.add(tenantimage);
var response = await request.send();

这是我返回发送值作为响应时的结果

 Array
(
 [property_id] => 2
 [unit_id] => 1463
 [tenant_name] => aqws
 [additional_terms] => awedswer
)

但是我想实现为“ unit_id”和“ additional_terms”作为数组? 像这样

 Array
(
 [property_id] => 2
 [unit_id] => Array
 (
 [0]
 )
 [tenant_name] => aqws
 [additional_terms] => Array
 (
 [0]=> awedswer
 [1]=> bilk
 )
)

解决方法

尝试:-

request.fields['additional_terms'] = "[{"shop_id":"1","product_id":1,"unit_price":188.0,"quantity":1,"discounted_price":0.0}]"