0
改造2我将如何POST使用具有内部json的地图json体。让我告诉你一个例子:改造地图为身体 - 如何张贴与内部json对象的地图
{
"id_invoice": 1234,
"action": "viewed",
"data": {
"id_object": 88,
"id_store": 43,
"type": "payment"
}
}
公告“数据” JSON对象如何具有内部JSON。我怎样才能放入地图这一切的话,我可以把它使用以下服务端点改造:
public interface Api {
@NonNull
@POST("cart/payment")
@Headers({"Content-Type:application/json"})
Observable<ResponseBody> postPaymentEvent(@Body Map<String, Object> body);
}
我试过如下:
Map<String, Object> map = new HashMap<>();
JSONObject json = new JSONObject();
json.put("id_object", 88);
json.put("id_store", 43);
json.put("type", "payment");
map.put("action", "view");
map.put("id_invoice", 1234);
map.put("data", json); //this is wrong. it creates the following response with a nameValuePairs field, which is not what i want:
身体:
{
"action": "page_view",
"id_invoice": "1234",
"data": {
"nameValuePairs": {
"id_object": 88,
"id_store": 43,
"type": "view"
}
}
}
我需要一个HashMap中。 – j2emanue
你是否在散列图中添加了其他东西? –
不,我只需要将该json放入地图中即可。显然,我可以使用一个类和gson。但是试图与地图 – j2emanue