We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Merge Multiple JSON key value into single array

rahulrockkk
Tera Contributor

Hi Team,

 

How to merge the multiple JSON key-value pair in the client-side script?

Current Format:

 

{"name1":"test1","name2":"test2"},{"name3":"test3","name4":"test4"}

 

Expected Format:

 

[{"name1":"test1","name2":"test2"},{"name3":"test3","name4":"test4"}]

1 REPLY 1

Geoff_T
Mega Sage

Hello,

You can just push the value to the array like:

var data = {"name1":"test1","name2":"test2"},{"name3":"test3","name4":"test4"};

var dataArray = [];
dataArray.push(data);

 

Geoff