我有一个JSON数据,我需要在POST方法中传递它。我不知道如何将JSON数据转换为查询参数。请帮助我如何使用洪水在POST方法中发送这种类型的JSON数据。
+ "&user=root&"
这是我实际上尝试过的:
jsonData = {
"author": "urn:li:person:12345",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Hello World! This is my first Share on LinkedIn!"
},
"shareMediaCategory": "NONE"
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
我希望:
params = Map();
params.put(“ author”,“ urn:li:person:12345”);
params.put(“ lifecycleState”,“发布”);
...等等
谢谢。
答案 0 :(得分:1)
我发现了大量代码,将JSON数据转换为查询参数。
param = Map();
param.put("author","urn:li:person:YoTjU8Fmfk");
param.put("lifecycleState","PUBLISHED");
specificContent = Map();
ShareContent = Map();
shareCommentary = Map();
shareCommentary.put("text","Hello World! This is my first Share on LinkedIn!");
ShareContent.put("shareCommentary",shareCommentary);
specificContent.put("com.linkedin.ugc.ShareContent",ShareContent);
specificContent.put("shareMediaCategory","NONE");
param.put("specificContent",specificContent);
visibility = Map();
visibility.put("com.linkedin.ugc.MemberNetworkVisibility","PUBLIC");
param.put("visibility",visibility);