Bug 825 - upload of add-ons failed to report their result because of trailing commas in the JSON response, r=Even.
authorFlorian Queze <florian@instantbird.org>
Thu Jun 09 23:31:10 2011 +0200 (11 months ago)
changeset 2319bb9721c17b
parent 22 55c8f7a3a002
child 24 e94fd12a09f4
Bug 825 - upload of add-ons failed to report their result because of trailing commas in the JSON response, r=Even.
site/app/views/helpers/listing.php
     1.1 --- a/site/app/views/helpers/listing.php
     1.2 +++ b/site/app/views/helpers/listing.php
     1.3 @@ -85,20 +85,24 @@
     1.4      function json($json, $tab = 0, $encode = false) {
     1.5          echo "{\n";
     1.6          if (!empty($json)) {
     1.7 +            $first = true;
     1.8              foreach ($json as $key => $value) {
     1.9 +                if (!$first)
    1.10 +                    echo ",\n";
    1.11                  echo str_repeat("\t", $tab)."\"{$key}\": ";
    1.12                  if (is_array($value))
    1.13                      $this->json($value, $tab + 1, $encode);
    1.14                  else
    1.15                      if (is_numeric($value) && strpos($value, '.') === false)
    1.16 -                        echo "{$value},\n";
    1.17 +                        echo "{$value}";
    1.18                      elseif ($encode)
    1.19 -                        echo '"'.urlencode($value).'",'."\n";
    1.20 +                        echo '"'.urlencode($value).'"';
    1.21                      else
    1.22 -                        echo "\"{$value}\",\n";
    1.23 +                        echo "\"{$value}\"";
    1.24 +                $first = false;
    1.25              }
    1.26          }
    1.27 -        echo str_repeat("\t", $tab).'}'.($tab == 0 ? '' : ',')."\n";
    1.28 +        echo str_repeat("\t", $tab)."}\n";
    1.29      }
    1.30      
    1.31  }