Skip to content

Tag: javascript-objects

Transform `Request` headers to plain key value object

I am trying to convert a list of headers from a Request (see object to a plain key/value object. Sadly, the following doesn’t work because the headers property is an iterator: Unusable result: Usable result but very verbose to create: I’m looking for some sort of a one liner (maybe including Array.from() or some of the other methods on

Transform JSON into required format

Here is my input JSON I need to transform json w.r.t parent category and what ever child json elements w.r.t parent to be in one format. All should be dynamic no hard coding comparing with strings. Need to transform my input json to below sampleformat, I tried separating parents and child values in an array and loop it and push.