0

I have a string with this value:

[{"email":"SharePoint.Admin_SA.external@test.net","id":"i:0#.w|opmain\\xespsa","label":"Admin_SA, SharePoint","title":"SharePoint Projektteam SP","type":"User","value":"i:0#.w|opmain\\xespsa"}]

The strings all have the same format. It can also be

[{"email":"SharePoint.Admin@test.net","id":"i:0#.w|opmain\\xespec","label":"Admin, SharePoint","title":"SharePoint Projektteam SP","type":"User","value":"i:0#.w|opmain\\xespec"}]

But I need a "global" approach, so that it always splits it at label. For example, splitting the first one should only output Admin_SA, SharePoint.

How can one achieve this?

I tried the following, but it didn't give me the result I wanted:

var test = NWF$("#" + varRequestor).val();
var array = test.split(':');
var a = array[0];
var b = array[1];
var c = array[2];
var d = array[3];
var e = array[4];

console.log("a: " + a);
console.log("b: " + b);
console.log("c: " + c);
console.log("d: " + d);
console.log("e: " + e);

enter image description here

I tried using JSON.parse as well, but it didn't work:

console.log("Requestor DispName: " + NWF$("#" + varRequestor).val());
var obj = NWF$("#" + varRequestor).val();
const test = JSON.parse(obj);
console.log("obj.label:" + obj.label);

enter image description here

stepbysteptomathpro
  • 455
  • 1
  • 7
  • 16

1 Answers1

1

i think, you want value corresponding to label. you can try this.

let temp = [{"email":"SharePoint.Admin_SA.external@test.net","id":"i:0#.w|opmain\\xespsa","label":"Admin_SA, SharePoint","title":"SharePoint Projektteam SP","type":"User","value":"i:0#.w|opmain\\xespsa"}];

console.log(temp[0].label);