diff --git a/runtime/base/json_parser.h b/runtime/base/json_parser.h index edbe03dbb8936fd1408ab5a9fca5715954ba9ccf..fd6644b0ff499e738eaf8669afad41274b2e162f 100644 --- a/runtime/base/json_parser.h +++ b/runtime/base/json_parser.h @@ -30,6 +30,7 @@ #include "plugins/ecmascript/runtime/js_handle.h" #include "plugins/ecmascript/runtime/js_tagged_value.h" #include "plugins/ecmascript/runtime/object_factory.h" +#include "plugins/ecmascript/es2panda/util/helpers.h" namespace panda::ecmascript::base { constexpr unsigned int UNICODE_DIGIT_LENGTH = 4; @@ -133,7 +134,11 @@ private: if (isFast) { std::string strNum(current_, end_ + 1); current_ = end_; - return JSTaggedValue(std::stod(strNum)); + auto d = std::stod(strNum); + if (es2panda::util::Helpers::IsInteger(d)) { + return JSTaggedValue(static_cast(d)); + } + return JSTaggedValue(d); } }