JSFiddle - React, Tailwind, and code Playground

by Mark Beharrell

HTML

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<div id="array">

</div>

JavaScript

var array = [{
  "level1": {
    "k1": "!£$%^&",
    "level2": [{
      "k2": "!£$%^&",
      "level3": [{
        "k3": "!£$%^&",
        "level3": [{
          "k4": "!%C2%A3%24%25%5E%26"
        }]
      }]
    }]
  }
}];

  function traverse(o) {
    $.each(o, function(i) {
      if (!!o[i] && typeof(o[i]) == "object") {
        traverse(o[i]);
      } else {
        try {
          o[i] = decodeURIComponent(o[i]);
        } catch (e) {}
        o[i] = encodeURIComponent(o[i]);
      }
    });
  }
  console.log(array);
  setTimeout(function() {
    traverse(array);
    console.log(array);
  }, 3000);