Add property to object based on its data
I have a list of records (CSV to JSON) where each row has a variable numbers of attributes in its columns. It could be something like
On the output object, I'd like to make a Record where the name is the key, and it points to an object based on the attribute data (name and value in this case).
So if the product type is (simplified):
Then there are two problems:
Attribute 1 name and Attribute 1 value, and so on for 2, 3, 4...On the output object, I'd like to make a Record where the name is the key, and it points to an object based on the attribute data (name and value in this case).
So if the product type is (simplified):
Then there are two problems:
- The
attributesproperty doesn't exist on the type, so it needs to be added. Right now I get amust be an object (was missing)error. How to add that without any type checking, so to speak? - Then I guess I need to pipe the product type and parse all the attributes there, so they can be added to the
attributesproperty, is that right?