Combining JSON arrays into a single JSON array -- better way than this?

ikelaiah iwan.kelaiah at gmail.com
Mon Aug 1 08:48:28 UTC 2022


On Monday, 1 August 2022 at 07:35:34 UTC, Christian Köstlin wrote:

> An arguably shorter solution (that drops some of your logging) 
> could be:
>
> ```d
> import std;
>
> void main() {
>     dirEntries(".", "*.json", SpanMode.shallow)
>         .filter!(f => !f.name.canFind("output"))
>         .map!(readText)
>         .map!(parseJSON)
>         .fold!((result, json) { result ~= json.array; return 
> result; })
>         .toPrettyString
>         .reverseArgs!(std.file.write)("output-combined.json");
> }
> ```
> not sure if you are looking for this style though.
>
>
> kind regards,
> Christian
> 

Hi Christian,

So we can do that in D?!
Thanks for sharing this amazing approach.

-ikelaiah



More information about the Digitalmars-d-learn mailing list