File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
java/client/src/org/openqa/selenium/json Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 2020import com .google .common .primitives .Primitives ;
2121
2222import java .lang .reflect .Type ;
23+ import java .math .BigDecimal ;
2324import java .util .Objects ;
2425import java .util .function .BiFunction ;
2526import java .util .function .Function ;
@@ -42,7 +43,23 @@ public boolean test(Class<?> type) {
4243 @ Override
4344 public BiFunction <JsonInput , PropertySetting , T > apply (Type ignored ) {
4445 return (jsonInput , setting ) -> {
45- Number number = jsonInput .nextNumber ();
46+ Number number ;
47+ switch (jsonInput .peek ()) {
48+ case NUMBER :
49+ number = jsonInput .nextNumber ();
50+ break ;
51+
52+ case STRING :
53+ try {
54+ number = new BigDecimal (jsonInput .nextString ());
55+ } catch (NumberFormatException e ) {
56+ throw new JsonException (e );
57+ }
58+ break ;
59+
60+ default :
61+ throw new JsonException ("Unable to coerce to a number: " + jsonInput .peek ());
62+ }
4663 return mapper .apply (number );
4764 };
4865 }
You can’t perform that action at this time.
0 commit comments