diff options
| author | gingerBill <bill@gingerbill.org> | 2019-01-06 22:25:02 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-01-06 22:25:02 +0000 |
| commit | 08598b9425ebaf06805cbf9b2fb09acbc29a3a64 (patch) | |
| tree | 435182aaf09aca0068d8ae54591140064732cc55 /core/encoding/json/validator.odin | |
| parent | 6295f6747fbbeeb849c2334c489d774051d78f6e (diff) | |
Support NaN and Infinity for JSON5
Diffstat (limited to 'core/encoding/json/validator.odin')
| -rw-r--r-- | core/encoding/json/validator.odin | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/core/encoding/json/validator.odin b/core/encoding/json/validator.odin index aa49364ec..332716e24 100644 --- a/core/encoding/json/validator.odin +++ b/core/encoding/json/validator.odin @@ -90,31 +90,33 @@ validate_array :: proc(p: ^Parser) -> bool { validate_value :: proc(p: ^Parser) -> bool { token := p.curr_token; + + using Kind; switch token.kind { - case Kind.Null: - advance_token(p); - return true; - case Kind.False: + case Null, False, True: advance_token(p); return true; - case Kind.True: + case Integer, Float: advance_token(p); return true; - case Kind.Integer: - advance_token(p); - return true; - case Kind.Float: - advance_token(p); - return true; - case Kind.String: + case String: advance_token(p); return is_valid_string_literal(token.text, p.spec); - case Kind.Open_Brace: + case Open_Brace: return validate_object(p); - case Kind.Open_Bracket: + case Open_Bracket: return validate_array(p); + + case: + if p.spec == Specification.JSON5 { + switch token.kind { + case Infinity, NaN: + advance_token(p); + return true; + } + } } return false; |