What is the best way to use requests and iopipe on gzipped JSON file

Steven Schveighoffer schveiguy at yahoo.com
Fri Oct 13 22:29:39 UTC 2017


On 10/13/17 6:24 PM, Andrew Edwards wrote:
> On Friday, 13 October 2017 at 21:53:12 UTC, Steven Schveighoffer wrote:
>> This has to be a misunderstanding. The point of runEncoded is to 
>> figure out the correct type (based on the BOM), and run your lambda 
>> function with the correct type for the whole thing.
> 
> Maybe I'm just not finding the correct words to express my thoughts. 
> This is what I mean:
> 
> // ===========
> 
> void main()
> {
>      auto url = 
> "http://api.syosetu.com/novelapi/api/?out=json&lim=500&gzip=5";
>      getContent(url)
>          .data
>          .unzip
>          .runEncoded!((input) {
>              char[] content; // Line 20
>              foreach (line; input.byLineRange!true) {
>                  content ~= line;
>              }
>          });
> }
> 
> output:
> source/app.d(20,13): Error: cannot append type wchar[] to type char[]
> 
> Changing line 20 to wchar yields:
> source/app.d(20,13): Error: cannot append type char[] to type wchar[]
> 
> And changing it to dchar[] yields:
> source/app.d(20,13): Error: cannot append type char[] to type dchar[]

Ah, OK. So the way runEncoded works is it necessarily instantiates your 
lambda with all types of iopipes that it might need. Then it decides at 
runtime which one to call.

So for a single call, it may be one of those 3, but always the same 
within the loop.

It might be tough to do it right, but moot point now, since it's not 
necessary anyway :)

-Steve


More information about the Digitalmars-d-learn mailing list