stdx.data.json - enhancement suggestions

Ilya Yaroshenko via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 1 13:02:45 PDT 2015


Current std.stdio is deprecated. This ad-hoc should works.

	auto json = File("fileName")
		.byChunk(1024 * 1024) //1 MB. Data cluster equals 1024 * 4
		.map!(ch => ch.idup)
		.joiner
		.map!(b => cast(char)b)
		.parseJSON;


On Friday, 1 May 2015 at 14:19:26 UTC, Laeeth Isharc wrote:
> On Wednesday, 29 April 2015 at 18:48:22 UTC, Laeeth Isharc 
> wrote:
>> Hi.
>>
>> What's the best way to pass the contents of a file to the 
>> stream parser without reading the whole thing into memory 
>> first?  I get an error if using byLine because the kind of 
>> range this function returns is not what the stream parser is 
>> expecting.
>>
>> There is an optional filename argument to parseJSONStream, but 
>> I am not sure what this is for, since it still requires the 
>> first argument for the input if the filename is passed.
>>
>>
>> Thanks.
>>
>>
>> Laeeth.
>
> some more suggestions for enhancements here:
> https://github.com/s-ludwig/std_data_json/issues/12
>
> a big advantage of languages like python is that there are 
> end-to-end examples of using the language+libraries to 
> accomplish real work.  (they don't need to be more than a 
> screenful of code, but for the newcomer having it all set out 
> makes a big difference).  since I believe a significant reason 
> for people to switch to D will be a realisation that actually 
> CPU time isn't free, it makes sense to be accommodating to 
> people who previously used scripting types of languages for 
> these jobs.
>
>
>
> Laeeth.


More information about the Digitalmars-d-learn mailing list