您好我正在制作一个Maven休息Web服务应用程序,我需要在我的JSONRest代码中获取hashmap值。我怎样才能做到这一点?如何在jsonrest脚本中hashmap值
这里是我的服务代码,打印出的JSON值:
@GET
@Path("/ind")
@Produces("application/json")
public HashMap<String,String> json()
{
HashMap<String,String> m = new HashMap<String,String>();
m.put("Fiyas", "basha");
m.put("Rajesh", "Babu");
JSONObject j = new JSONObject();
try {
if(j != null)
j.put("emp", m);
} catch (JSONException ex) {
ex.getMessage();
}
return m;
}
它打印{"Fiyas":"basha","Rajesh":"Babu"}
现在我需要把这种JSON值选择框在我的道场特定JSON EMP关键脚本
我JSONRest代码:
<script>
require(["dojo/store/JsonRest", "dojo/dom-construct"], function(JsonRest, domConst){
var store = new JsonRest({
target: "http://localhost:8080/userservices/rest/rest/ind",
});
store.query().then(function(jsonData){
alert(jsonData.emp);
domConst.place("<option value=''>Year's of Exp</option>","Experience");
for(var i in jsonData.emp)
{
domConst.place("<option value="+jsonData.emp[i]+">" + jsonData.emp[i] + "</option>","Experience");
}
});
});
</script>
我得到undefined
,并且无法获取此脚本中的值,但是我在firebug中获得了响应和JSON值。
如何逐个获取散列表值?请,任何帮助将不胜感激,并向我暗示我做错了什么。
请感谢