How about to a bit simplify the logic: try `JSON.parse(val.value)` first. If it fails - wrap it with `[` and `]` and try again? No need to regex, no need to map and make multiple `JSON.parse` calls.