Re: Stripping [ ] from JSON arrays
Y A <[email protected]> Thu, 16 Feb 2023 04:50:49 -0800 (PST)
| Newsgroups | comp.lang.php |
|---|---|
| Message-ID | <[email protected]> |
You have looked out: http://webchatsoftware.ezyro.com ?
On Tuesday, January 10, 2023 at 6:29:21 AM UTC+2, JJ wrote:
> On Tue, 10 Jan 2023 01:17:47 -0000 (UTC), The Doctor wrote:
> >
> > How do I strip unnecessary [] ?
> I'd use array's `reduce()` for that. e.g.
>
> var resultObj = theArray.reduce((res, obj) => Object.assign(res, obj), {});