@@ -12,7 +12,7 @@ const false_in_string = 'false'
1212
1313const float_zero_in_string = '0.0'
1414
15- const whitespace_chars = [` ` , `\t ` , `\n ` ]!
15+ const whitespace_chars = [` ` , `\t ` , `\n ` , ` \r ` ]!
1616
1717// Node represents a node in a linked list to store ValueInfo.
1818struct Node [T] {
@@ -315,9 +315,6 @@ fn (mut checker Decoder) check_json_format(val string) ! {
315315 // check if the JSON string is an empty array
316316 if checker_end > = checker.checker_idx + 2 {
317317 checker.checker_idx++
318- if val[checker.checker_idx] == `]` {
319- return
320- }
321318 } else {
322319 return checker.error ('EOF error: There are not enough length for an array' )
323320 }
@@ -332,7 +329,7 @@ fn (mut checker Decoder) check_json_format(val string) ! {
332329 }
333330
334331 if val[checker.checker_idx] == `]` {
335- return
332+ break
336333 }
337334
338335 if checker.checker_idx > = checker_end - 1 {
@@ -806,8 +803,7 @@ fn (mut decoder Decoder) decode_value[T](mut val T) ! {
806803 $if field.typ is $option {
807804 // it would be nicer to do this at the start of the function
808805 // 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 {
811807 val.$(field.name) = none
812808 } else {
813809 mut unwrapped_val := create_value_from_optional (val.$(field.name)) or {
@@ -981,18 +977,6 @@ fn create_value_from_optional[T](val ?T) ?T {
981977 return T{}
982978}
983979
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-
996980// string_buffer_to_generic_number converts a buffer of bytes (data) into a generic type T and
997981// stores the result in the provided result pointer.
998982// The function supports conversion to the following types:
0 commit comments