diff --git a/json_object.c b/json_object.c index e6bd870..b493b69 100644 --- a/json_object.c +++ b/json_object.c @@ -509,6 +509,8 @@ static int json_object_int_to_json_string(struct json_object* jso, int level, int flags) { + if (flags & JSON_C_TO_STRING_UINT64) + return sprintbuf(pb, "%"PRIu64, jso->o.c_int64); return sprintbuf(pb, "%"PRId64, jso->o.c_int64); } diff --git a/json_object.h b/json_object.h index 5e0cf71..871b971 100644 --- a/json_object.h +++ b/json_object.h @@ -62,6 +62,11 @@ extern "C" { * A flag to drop trailing zero for float values */ #define JSON_C_TO_STRING_NOZERO (1<<2) +/** + * Force integer to output unsigned + * Useful when dealing with very large 64 bit numbers without negatives + */ +#define JSON_C_TO_STRING_UINT64 (1<<4) #undef FALSE #define FALSE ((json_bool)0)