mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-23 06:52:30 +00:00
Add strbuf_json_integer()
This commit is contained in:
parent
c7a2fb4573
commit
798e34cc5b
@ -716,6 +716,12 @@ strbuf strbuf_json_boolean(strbuf sb, int boolean)
|
||||
return sb;
|
||||
}
|
||||
|
||||
strbuf strbuf_json_integer(strbuf sb, int64_t integer)
|
||||
{
|
||||
strbuf_sprintf(sb, "%"PRId64, integer);
|
||||
return sb;
|
||||
}
|
||||
|
||||
static const uint32_t offsetsFromUTF8[6] = {
|
||||
0x00000000UL, 0x00003080UL, 0x000E2080UL,
|
||||
0x03C82080UL, 0xFA082080UL, 0x82082080UL
|
||||
@ -820,8 +826,7 @@ strbuf strbuf_json_atom(strbuf sb, const struct json_atom *atom)
|
||||
case JSON_BOOLEAN:
|
||||
return strbuf_json_boolean(sb, atom->u.boolean);
|
||||
case JSON_INTEGER:
|
||||
strbuf_sprintf(sb, "%"PRId64, atom->u.integer);
|
||||
return sb;
|
||||
return strbuf_json_integer(sb, atom->u.integer);
|
||||
case JSON_STRING_NULTERM:
|
||||
return strbuf_json_string(sb, atom->u.string.content);
|
||||
case JSON_STRING_LENGTH:
|
||||
|
@ -234,6 +234,7 @@ strbuf strbuf_html_escape(strbuf sb, const char *, size_t);
|
||||
*/
|
||||
strbuf strbuf_json_null(strbuf sb);
|
||||
strbuf strbuf_json_boolean(strbuf sb, int boolean);
|
||||
strbuf strbuf_json_integer(strbuf sb, int64_t integer);
|
||||
strbuf strbuf_json_string(strbuf sb, const char *str); // str can be NULL
|
||||
strbuf strbuf_json_string_len(strbuf sb, const char *str, size_t strlen); // str cannot be NULL
|
||||
strbuf strbuf_json_hex(strbuf sb, const unsigned char *buf, size_t len);
|
||||
|
Loading…
Reference in New Issue
Block a user