title: Recursively decode JSON string until the decoded string is a valid JSON
body: <p>I have a one-time URL encoded string:</p>
  
  <pre><code>$encodedJson = "%5B%7B%0A%09%22base%22%3A%20%7B%0A%09%09%22url%22%3A%20%22abc.com%22%2C%0A%09%09%22referrer%22%3A%20%22xyz.com%22%0A%09%7D%0A%7D%2C%20%7B%0A%09%22client%22%3A%20%7B%0A%09%09%22Pixel%22%3A%20false%2C%0A%09%09%22screen%22%3A%20%221680x1050%22%0A%09%7D%0A%7D%5D"
  </code></pre>
  
  <p>If I use the following functions, I have a decoded JSON, which is an array: </p>
  
  <pre><code>$decodedJsonArray = json_decode(rawurldecode($encodedJson), true);
  </code></pre>
  
  <p>Then <code>print_r($decodedJsonArray);</code> gives me the desired output: </p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [base] =&gt; Array
                  (
                      [url] =&gt; abc.com
                      [referrer] =&gt; xyz.com
                  )
  
          )
  
      [1] =&gt; Array
          (
              [client] =&gt; Array
                  (
                      [Pixel] =&gt; 
                      [screen] =&gt; 1680x1050
                  )
  
          )
  
  )
  </code></pre>
  
  <p>Now, let's say I have a multiple-times URL encoded string: </p>
  
  <pre><code>$encodedJson = "%25255B%25257B%25250A%252509%252522base%252522%25253A%252520%25257B%25250A%252509%252509%252522url%252522%25253A%252520%252522abc.com%252522%25252C%25250A%252509%252509%252522referrer%252522%25253A%252520%252522xyz.com%252522%25250A%252509%25257D%25250A%25257D%25252C%252520%25257B%25250A%252509%252522client%252522%25253A%252520%25257B%25250A%252509%252509%252522Pixel%252522%25253A%252520false%25252C%25250A%252509%252509%252522screen%252522%25253A%252520%2525221680x1050%252522%25250A%252509%25257D%25250A%25257D%25255D"
  </code></pre>
  
  <p>This string is three-times URL encoded. Now, I want to achieve the same JSON array as before. I am trying to write a function similar to the following: </p>
  
  <pre><code>function recursiveJsonDecode($encodedJson) {
      if (isJson($encodedJson)) {
          return $encodedJson;
      } else {
          $decodedJsonArray = json_decode(rawurldecode($encodedJson), true);
          return $decodedJsonArray;
      }
  }
  </code></pre>
  
  <p>But it's not working. Any help would be much appreciated.</p>