mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-21 12:05:05 +00:00
Preserve the original string representation of numbers too.
Not always useful, but sometimes it will be.
This commit is contained in:
parent
0509a860fb
commit
73cf86acdb
@ -99,7 +99,9 @@ have no additional data.
|
||||
Strings have type <code>JSON_STRING</code>, with null-terminated UTF-8 text
|
||||
in <code>string</code> and length in <code>length</code>.
|
||||
|
||||
Numbers have type <code>JSON_NUMBER</code>, with value in <code>number</code>.
|
||||
Numbers have type <code>JSON_NUMBER</code>, with value in <code>number</code>,
|
||||
and also preserve the original representation of the number
|
||||
in <code>string</code> and length in <code>length</code>.
|
||||
|
||||
Arrays have type <code>JSON_ARRAY</code>. There are <code>length</code> elements in the array,
|
||||
and the elements are in <code>array</code>.
|
||||
|
@ -414,8 +414,11 @@ again:
|
||||
json_object *n = add_object(j, JSON_NUMBER);
|
||||
if (n != NULL) {
|
||||
n->number = atof(val.buf);
|
||||
n->string = val.buf;
|
||||
n->length = val.n;
|
||||
} else {
|
||||
string_free(&val);
|
||||
}
|
||||
string_free(&val);
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -542,7 +545,7 @@ void json_free(json_object *o) {
|
||||
|
||||
free(k);
|
||||
free(v);
|
||||
} else if (o->type == JSON_STRING) {
|
||||
} else if (o->type == JSON_STRING || o->type == JSON_NUMBER) {
|
||||
free(o->string);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user