Skip to content

Commit

Permalink
opt: add decoder Option NoValidateJSON to use fast-skip when skippi…
Browse files Browse the repository at this point in the history
…ng on decoding (mismatched-type, remained-elems)
  • Loading branch information
AsterDY committed Aug 25, 2024
1 parent e0a4098 commit 573c34a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/decoder/consts/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ const (
F_disable_unknown = 3
F_copy_string = 4


F_use_number = types.B_USE_NUMBER
F_validate_string = types.B_VALIDATE_STRING
F_allow_control = types.B_ALLOW_CONTROL
F_no_validate_json = types.B_NO_VALIDATE_JSON
)

type Options uint64
Expand All @@ -26,6 +28,7 @@ const (
OptionDisableUnknown Options = 1 << F_disable_unknown
OptionCopyString Options = 1 << F_copy_string
OptionValidateString Options = 1 << F_validate_string
OptionNoValidateRawJSON Options = 1 << F_no_validate_json
)

const (
Expand Down
1 change: 1 addition & 0 deletions internal/decoder/jitdec/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
_F_disable_urc = consts.F_disable_urc
_F_use_int64 = consts.F_use_int64
_F_use_number = consts.F_use_number
_F_no_validate_json = consts.F_no_validate_json
_F_validate_string = consts.F_validate_string
)

Expand Down
3 changes: 3 additions & 0 deletions internal/native/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const (
B_USE_NUMBER = 1
B_VALIDATE_STRING = 5
B_ALLOW_CONTROL = 31

// for native.SkipOne() flags
B_NO_VALIDATE_JSON= 6
)

const (
Expand Down
1 change: 1 addition & 0 deletions native/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#define F_DBLUNQ (1 << 0)
#define F_UNIREP (1 << 1)
#define F_NO_VALIDATE_JSON (1 << 6)

#define VS_NULL 0x6c6c756e // 'null' in little endian
#define VS_TRUE 0x65757274 // 'true' in little endian
Expand Down

0 comments on commit 573c34a

Please sign in to comment.