Skip to content

Commit bdc6e8a

Browse files
committed
fix: try catch valueType object or json
1 parent 055f5ca commit bdc6e8a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/getValue.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ const getValue = (element) => {
9898
value = [value];
9999
}
100100

101-
if (valueType == 'object' || valueType == 'json') {
102-
value = JSON.parse(value)
101+
if (value && (valueType == 'object' || valueType == 'json')) {
102+
try {
103+
value = JSON.parse(value)
104+
} catch (error) {
105+
value = value
106+
}
103107
}
104108

105-
106109
return value;
107110
};
108111

0 commit comments

Comments
 (0)