Advertisement
Militsa

14. Parse JSON Objects

Dec 25th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function parseJSONObjects(arr) {
  2.     let array = new Array();
  3.     for(let string of arr) {
  4.         let object = JSON.parse(string);
  5.         array.push(object);
  6.     }
  7.  
  8.     for(let object of array) {
  9.         for(let key of Object.keys(object)) {
  10.             console.log(`${key.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();})}: ${object[key]}`)
  11.         }
  12.     }
  13. }
  14.  
  15. //parseJSONObjects(['{"name":"Gosho","age":10,"date":"19/06/2005"}','{"name":"Tosho","age":11,"date":"04/04/2005"}']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement