我有一个Sharepoint 2013客户端人员选择器。它返回以下结构:
<input id="peoplePickerDiv1_TopSpan_HiddenInput" name="peoplePickerDiv1_TopSpan_HiddenInput" type="hidden" value="
[{"Key":"i:0#.w|XXXXX\\tkabcs","Description"
:"XXXXX\\tkabcs","DisplayText"
:"ABCDE, ABC-DEF","EntityType":"User"
,"ProviderDisplayName":"Active Directory","ProviderName":"AD","IsResolved"
:true,"EntityData":,"MultipleMatches":}]">
如何在值属性中访问类似“Key”的内容?
(抱歉结构不好,不得不从控制台日志中取出)
答案 0 :(得分:2)
该输入的值看起来像JSON,除了它在字符串末尾附近有两个语法错误。我不得不改变:
$(".sub-menu > li:first-child").each(function(){
var parent = $(this).parent('ul').parent('.has-sub-menu');
var copy = parent.clone();
$(copy).removeClass("has-sub-menu").find(".sub-menu").remove();
$(copy).prepend('Über: ');
$(this).before(copy);
});
$('.has-sub-menu > a').attr('href' ,'#');
为:
EntityData":,"MultipleMatches":}]
(删除额外的,并且:)
通过这些更改,我能够将字符串解析为对象并访问密钥。
EntityData":"MultipleMatches"}]