Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions core/io/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,25 @@ Error JSON::_get_token(const char32_t *p_str, int &index, int p_len, Token &r_to

if (p_str[index] == '-' || is_digit(p_str[index])) {
//a number
const char32_t *rptr;
double number = String::to_float(&p_str[index], &rptr);
index += (rptr - &p_str[index]);
r_token.type = TK_NUMBER;
r_token.value = number;
int sub_index = index + 1;
while (is_digit(p_str[sub_index])) {
sub_index++;
}

if (p_str[sub_index] == 'e' || p_str[sub_index] == 'E' || p_str[sub_index] == '.') {
// float detected
const char32_t *rptr;
const double number = String::to_float(&p_str[index], &rptr);
index += (rptr - &p_str[index]);
r_token.type = TK_NUMBER;
r_token.value = number;
} else {
// int detected
const int64_t number = String::to_int(&p_str[index], sub_index - index);
index = sub_index;
r_token.type = TK_NUMBER;
r_token.value = number;
}
return OK;

} else if (is_ascii_alphabet_char(p_str[index])) {
Expand Down
Loading