Advertisement
cornford-michael

modify JSON

Apr 6th, 2023
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const arr = [
  2.   {
  3.     ems_id: "",
  4.     moc: "MRNC",
  5.     metadata: "",
  6.     isSSH: 0,
  7.     gsmRanShareSwitch: "",
  8.     ommPort: "21125",
  9.     ems4xId: "",
  10.     summerTimeoffset_1min: "60",
  11.     timeZoneoffset: 38,
  12.     nbiId: "201",
  13.     mcc: "510",
  14.     protocol: "tcp,emb",
  15.     administrativeState: 0,
  16.     radioMode: "",
  17.     omm_id: "",
  18.     summTimeStart: "0-0 0:0",
  19.     networkingMode: "",
  20.     id: "cbab3f92-1dd3-465f-976e-27dd1818ec4b",
  21.     longitude: "0.0",
  22.     nbiotRanShareSwitch: "",
  23.     sshPort: "0",
  24.     mimVersion: "BSCV4_V12.18.41P02",
  25.     summerTimeoffset: "4",
  26.     ommFtpPasswd: "22D1DC944113D348D884D6278CA371AD",
  27.     ommFtpPort: "21",
  28.     connectionState: 1,
  29.     ipAddress: "129.0.1.1",
  30.     plmn: "510-10",
  31.     priority: "2",
  32.     vendorName: "ZTE",
  33.     version: "V4.17.10",
  34.     productInfo: "GSM",
  35.     lteRanShareSwitch: "",
  36.     port: "",
  37.     ommSecretKeyId: "KEY_AES256_UEP_20110623",
  38.     ltetddRanShareSwitch: "",
  39.     name: "BSCZ_SML(201)(201)",
  40.     subType: "GSM",
  41.     maintainStatus: "0",
  42.     operationalState: 1,
  43.     ommConnectionState: 1,
  44.     ommIpAddress: "10.251.169.67",
  45.     summerTimeoffsetType: 0,
  46.     originalType: "",
  47.     timezone: "",
  48.     displayName: "BSCZ_SML(201)(201)",
  49.     latitude: "0.0",
  50.     description: "SML-TEOCO-BSC-A",
  51.     oid: "urop:OMMOID=603d8e89-PA@sbn=201@me=201",
  52.     ltefddRanShareSwitch: "",
  53.     configProductInfo: "GSM",
  54.     userdefinedState: "0",
  55.     cmDataFreeze: "",
  56.     summTimeEnd: "0-0 0:0",
  57.     isSuppSummTime: 0,
  58.     managedFunctionInfo: "BSC",
  59.     swInfo: "V4.17.10",
  60.     umtsRanShareSwitch: "",
  61.     timeZoneoffset_15min: "GMT+07:00",
  62.     mnc: "10",
  63.     ommFtpUser: "uep",
  64.     ranShareSwitch: 0,
  65.     maintainState: "0",
  66.     nrRanShareSwitch: "",
  67.     ommFtpType: "ftp",
  68.     location: "",
  69.     subnetwork_nbiId: "201",
  70.   },
  71. ]
  72.  
  73. let obj = arr[0];
  74.  
  75. let newObj = []
  76.  
  77.  
  78. const keys = Object.keys(obj);
  79. const vals = Object.values(obj);
  80. const entries = Object.entries(obj);
  81.  
  82. console.log(keys)
  83. console.log(vals)
  84. console.log(entries)
  85.  
  86. entries.forEach((e, i) => {
  87.   e = {caption: e[0],param: e[0], value: e[1] };
  88.   newObj.push(e);
  89. });
  90.  
  91. console.log(obj)
  92. console.log(newObj)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement