bytedance / sonic-cpp

A fast JSON serializing & deserializing library, accelerated by SIMD.
Apache License 2.0
835 stars 101 forks source link

Proposal: Support parsing JSON number as RawNumber type #61

Open liuq19 opened 1 year ago

liuq19 commented 1 year ago

In order to parse JSON numbers with full precision and improve parsing performance, we propose adding a new RawNumber type for representing parsed JSON number values.

The design of this feature includes the following steps:

  1. Add a new kRawNumber enum to represent JSON number values, and add a RawNumberclass to distinguish it from stringview type.
  2. Provide support for construct, modifying, copying, and comparing RawNumber values. Especially, validate the number in construct and set API, because the number is from the user and maybe invalid numbers
  3. Use IsRawNumber to check for the presence of a RawNumber, while IsNumber continues to check for numeric types.

Implementation branch: #60 Status: To be reviewed.