@@ -12,7 +12,7 @@ const false_in_string = 'false'
12
12
13
13
const float_zero_in_string = '0.0'
14
14
15
- const whitespace_chars = [` ` , `\t ` , `\n ` ]!
15
+ const whitespace_chars = [` ` , `\t ` , `\n ` , ` \r ` ]!
16
16
17
17
// Node represents a node in a linked list to store ValueInfo.
18
18
struct Node [T] {
@@ -315,9 +315,6 @@ fn (mut checker Decoder) check_json_format(val string) ! {
315
315
// check if the JSON string is an empty array
316
316
if checker_end > = checker.checker_idx + 2 {
317
317
checker.checker_idx++
318
- if val[checker.checker_idx] == `]` {
319
- return
320
- }
321
318
} else {
322
319
return checker.error ('EOF error: There are not enough length for an array' )
323
320
}
@@ -332,7 +329,7 @@ fn (mut checker Decoder) check_json_format(val string) ! {
332
329
}
333
330
334
331
if val[checker.checker_idx] == `]` {
335
- return
332
+ break
336
333
}
337
334
338
335
if checker.checker_idx > = checker_end - 1 {
@@ -806,8 +803,7 @@ fn (mut decoder Decoder) decode_value[T](mut val T) ! {
806
803
$if field.typ is $option {
807
804
// it would be nicer to do this at the start of the function
808
805
// but options cant be passed to generic functions
809
- if decoder.current_node.value.length == 4
810
- && decoder.json[decoder.current_node.value.position..decoder.current_node.value.position + 4 ] == 'null' {
806
+ if decoder.current_node.value.value_kind == .null {
811
807
val.$(field.name) = none
812
808
} else {
813
809
mut unwrapped_val := create_value_from_optional (val.$(field.name)) or {
@@ -981,18 +977,6 @@ fn create_value_from_optional[T](val ?T) ?T {
981
977
return T{}
982
978
}
983
979
984
- fn utf8_byte_len (unicode_value u32 ) int {
985
- if unicode_value < = 0x7F {
986
- return 1
987
- } else if unicode_value < = 0x7FF {
988
- return 2
989
- } else if unicode_value < = 0xFFFF {
990
- return 3
991
- } else {
992
- return 4
993
- }
994
- }
995
-
996
980
// string_buffer_to_generic_number converts a buffer of bytes (data) into a generic type T and
997
981
// stores the result in the provided result pointer.
998
982
// The function supports conversion to the following types:
0 commit comments