I have a column with following contents in Open Refine
1. {"result":"Mango"}
2. {"result":"Banana"},{"result":"Apple"}
and I need resulting column
1. Mango
2. Banana | Apple
The expression I tried was
"forEach(value.parseJson().result).join(' | ')"
but this does not produce results.
CodePudding user response:
Your second example isn't valid JSON, so I'm not sure what the parse will produce -- probably just the first object. One approach would be to wrap each cell with square brackets ([]
) to turn it into a JSON array. This will give you something that forEach
can operate on.
CodePudding user response:
Thanks @Tom Morris
Modified cells as
1. [{"result":"Mango"}]
2. [{"result":"Banana"},{"result":"Apple"}]
Then solution used was
forEach(value.parseJson(),v,v.result).join(' | ')