how to phrase multi row variable set JSON

String
Kilo Sage

Hi Team,

We are using client controller to fetch values MRVS from catalog item 

 

"[{\"asset_details\":\"0f19a6518787d11089e3c8490cbb35bb\",\"u_order\":\"1\",\"chargeable\":\"true\",\"amount\":\"\",\"shipto_loc\":\"Finland\",\"total_qty\":\"\",\"u_consumable\":\"4c61ce9e87d4a51089e3c8490cbb350b\",\"u_price\":\"\",\"IO:f50ea9bb8791251089e3c8490cbb3532\":\"false\",\"product_name\":\"ab775db51b31951009952f02604bcbeb\",\"max_qty\":\"\"}]"

 

Please help me parse and get respective values 

1 ACCEPTED SOLUTION

Prince Arora
Tera Sage
Tera Sage

@Laszlo Balla ,

 

Please use below format:

 

var mvrs = 

"[{\"asset_details\":\"0f19a6518787d11089e3c8490cbb35bb\",\"u_order\":\"1\",\"chargeable\":\"true\",\"amount\":\"\",\"shipto_loc\":\"Finland\",\"total_qty\":\"\",\"u_consumable\":\"4c61ce9e87d4a51089e3c8490cbb350b\",\"u_price\":\"\",\"IO:f50ea9bb8791251089e3c8490cbb3532\":\"false\",\"product_name\":\"ab775db51b31951009952f02604bcbeb\",\"max_qty\":\"\"}]";

var json = JSON.parse(mvrs);

for(var i = 0 ; i < json.length ; i++){

var assetDetails = json [i].asset_details;

var u_order= json [i].u_order;

}

And same for all the variables...

 

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact!

View solution in original post

2 REPLIES 2

Laszlo Balla
ServiceNow Employee
ServiceNow Employee

Check this article.

Prince Arora
Tera Sage
Tera Sage

@Laszlo Balla ,

 

Please use below format:

 

var mvrs = 

"[{\"asset_details\":\"0f19a6518787d11089e3c8490cbb35bb\",\"u_order\":\"1\",\"chargeable\":\"true\",\"amount\":\"\",\"shipto_loc\":\"Finland\",\"total_qty\":\"\",\"u_consumable\":\"4c61ce9e87d4a51089e3c8490cbb350b\",\"u_price\":\"\",\"IO:f50ea9bb8791251089e3c8490cbb3532\":\"false\",\"product_name\":\"ab775db51b31951009952f02604bcbeb\",\"max_qty\":\"\"}]";

var json = JSON.parse(mvrs);

for(var i = 0 ; i < json.length ; i++){

var assetDetails = json [i].asset_details;

var u_order= json [i].u_order;

}

And same for all the variables...

 

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact!