mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Preserve the original string representation of numbers too.
Not always useful, but sometimes it will be.
This commit is contained in:
@@ -99,7 +99,9 @@ have no additional data.
|
|||||||
Strings have type <code>JSON_STRING</code>, with null-terminated UTF-8 text
|
Strings have type <code>JSON_STRING</code>, with null-terminated UTF-8 text
|
||||||
in <code>string</code> and length in <code>length</code>.
|
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,
|
Arrays have type <code>JSON_ARRAY</code>. There are <code>length</code> elements in the array,
|
||||||
and the elements are in <code>array</code>.
|
and the elements are in <code>array</code>.
|
||||||
|
|||||||
+5
-2
@@ -414,8 +414,11 @@ again:
|
|||||||
json_object *n = add_object(j, JSON_NUMBER);
|
json_object *n = add_object(j, JSON_NUMBER);
|
||||||
if (n != NULL) {
|
if (n != NULL) {
|
||||||
n->number = atof(val.buf);
|
n->number = atof(val.buf);
|
||||||
|
n->string = val.buf;
|
||||||
|
n->length = val.n;
|
||||||
|
} else {
|
||||||
|
string_free(&val);
|
||||||
}
|
}
|
||||||
string_free(&val);
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,7 +545,7 @@ void json_free(json_object *o) {
|
|||||||
|
|
||||||
free(k);
|
free(k);
|
||||||
free(v);
|
free(v);
|
||||||
} else if (o->type == JSON_STRING) {
|
} else if (o->type == JSON_STRING || o->type == JSON_NUMBER) {
|
||||||
free(o->string);
|
free(o->string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user