Issue 1560: The REST API for ls-projects returns spurious JSON
Status:  WontFix
Owner: ----
Closed:  Sep 2012
Reported by michele....@gmail.com, Sep 14, 2012
************************************************************
***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL *****
***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.    *****
***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS!  *****
************************************************************

Affected Version: 2.5-rc0

What steps will reproduce the problem?
1. Open [gerrit_base_url]/projects/?format=JSON&tree

What is the expected output? What do you see instead?

Expected: a JSON object containing a hierarchy of projects.
Actual: the expected JSON object, preceeded by a line containing ")]}'"

See the attached file for the actual output returned by Gerrit
projects
795 bytes   View   Download
Sep 14, 2012
Project Member #1 edwin.ke...@gmail.com
This prefix is intended to be there. You need to skip it when parsing the response.
This is documented in the Gerrit Rest API documentation [1].

In the code this prefix is explained like this:
" /**
   * Expected JSON content body prefix that prevents XSSI.
   * <p>
   * The server always includes this line as the first line of the response
   * content body when the response body is formatted as JSON. It gets inserted
   * by the server to prevent the resource from being imported into another
   * domain's page using a &lt;script&gt; tag. This line must be removed before
   * the JSON can be parsed.
   */
"

[1] https://gerrit-review.googlesource.com/Documentation/rest-api.html#output

Status: WontFix