I'm running this on windows 10, power shell. I even took the out put from the curl invoke and copied it to your online testing - both fail. From what I can tell jq only can take JSON input and the is error out on the other syntax.
Issue I see in power shell
parse error: Invalid numeric literal at line 3, column 11
Issue I see in jq play:
parse error: Invalid numeric literal at line 1, column 11
@lbrader - I took the output of the curl command you gave and fed it to jplay.org without incident. It occurs to me that perhaps you have not adapted your command-line commands to the Windows environment. For example, you will probably need to use double-quotation marks, or in the case of ".", you could simply omit the quotation marks.
The issue is that curl when run from Powershell uses the Invoke-WebRequest cmdlet (whose aliases are curl & wget). The response of the cmdlet is not just the json content of the response. But it is in this format.
StatusCode : 200
StatusDescription : OK
Content : [{"sha":"0b8218515eabf1a967eba0dbcc7a0e5ae031a509","commit":{"author":{"name":"Nicolas Williams","e
mail":"[email protected]","date":"2016-03-21T22:43:01Z"},"committer":{"name":"Nicolas
Williams","...
RawContent : HTTP/1.1 200 OK
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 52
X-RateLimit-Reset: 1470350889
Vary: Accept,Accept-Encoding
X-GitHub-Media-Type: github.v3; format=json
Link:
Headers : {[Status, 200 OK], [X-RateLimit-Limit, 60], [X-RateLimit-Remaining, 52], [X-RateLimit-Reset,
1470350889]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 14852
Hence you would need to use the return Object's Content attribute to pipe it to jq.
Change your command line to
curl -Uri 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | Select Content -Expand Content | jq -C '.'
This will work.
Also both Single & double quoted strings work.
| Select Content -Expand Content
yea, it's work
Most helpful comment
The issue is that curl when run from Powershell uses the Invoke-WebRequest cmdlet (whose aliases are curl & wget). The response of the cmdlet is not just the json content of the response. But it is in this format.
StatusCode : 200
Forms : {}
StatusDescription : OK
Content : [{"sha":"0b8218515eabf1a967eba0dbcc7a0e5ae031a509","commit":{"author":{"name":"Nicolas Williams","e
mail":"[email protected]","date":"2016-03-21T22:43:01Z"},"committer":{"name":"Nicolas
Williams","...
RawContent : HTTP/1.1 200 OK
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 52
X-RateLimit-Reset: 1470350889
Vary: Accept,Accept-Encoding
X-GitHub-Media-Type: github.v3; format=json
Link:
Headers : {[Status, 200 OK], [X-RateLimit-Limit, 60], [X-RateLimit-Remaining, 52], [X-RateLimit-Reset,
1470350889]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 14852
Hence you would need to use the return Object's Content attribute to pipe it to jq.
Change your command line to
curl -Uri 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | Select Content -Expand Content | jq -C '.'
This will work.
Also both Single & double quoted strings work.