您好我从我的Java应用程序中发送了HashMap<String, List<MyObject>>
,如下所示:
{
"316N": [
{
"userCreate": null,
"dateCreate": null,
"userMaj": null,
"dateMaj": null,
"archive": false,
"nomComposant": "cob",
"versionComposant": 2,
"checksumSrcComposant": "1235",
"checksumBinComposant": "1235"
}
]
}
有没有办法简单地将这个json对象解析为Map或sthg来自一个我不知道的酷javascript lib(在lodash中找不到)。
答案 0 :(得分:3)
只需使用Map
构造函数获取Object.entries
new Map( Object.entries( obj ) )
<强>演示强>
var obj = {
"316N": [
{
"userCreate": null,
"dateCreate": null,
"userMaj": null,
"dateMaj": null,
"archive": false,
"nomComposant": "cob",
"versionComposant": 2,
"checksumSrcComposant": "1235",
"checksumBinComposant": "1235"
}
]
};
var output = new Map( Object.entries( obj ) );
var mapIter = output.entries();
console.log(mapIter.next().value);
&#13;