Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,18 @@ if (NOT DEFINED JSON_INT_T)
# I am not sure what cygwin will want, so I will assume I64d

if (WIN32) # matches both msvc and cygwin
set (JSON_INTEGER_FORMAT "\"I64d\"")
check_c_source_compiles("
#include <stdio.h>
#if !defined(__MINGW32__) || !defined(_UCRT)
#error Not MinGW-w64 with UCRT
#endif
int main(void) { return 0; }
" HAVE_MINGW_UCRT)
if (HAVE_MINGW_UCRT)
set (JSON_INTEGER_FORMAT "\"lld\"")
else ()
set (JSON_INTEGER_FORMAT "\"I64d\"")
endif ()
else ()
set (JSON_INTEGER_FORMAT "\"lld\"")
endif ()
Expand Down
4 changes: 4 additions & 0 deletions src/jansson.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ typedef struct json_t {
#ifndef JANSSON_USING_CMAKE /* disabled if using cmake */
#if JSON_INTEGER_IS_LONG_LONG
#ifdef _WIN32
#if defined(__MINGW32__) && defined(_UCRT)
#define JSON_INTEGER_FORMAT "lld"
#else
#define JSON_INTEGER_FORMAT "I64d"
#endif
#else
#define JSON_INTEGER_FORMAT "lld"
#endif
Expand Down
14 changes: 14 additions & 0 deletions test/suites/api/test_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ static void encode_other_than_array_or_object() {
json_decref(json);
}

static void encode_large_integer() {
#if JSON_INTEGER_IS_LONG_LONG
json_t *json = json_integer(9007199254740993LL);
char *result = json_dumps(json, JSON_ENCODE_ANY);

if (!result || strcmp(result, "9007199254740993") != 0)
fail("json_dumps failed to encode a large integer exactly");

free(result);
json_decref(json);
#endif
}

static void escape_slashes() {
/* Test dump escaping slashes */

Expand Down Expand Up @@ -335,6 +348,7 @@ static void run_tests() {
encode_twice();
circular_references();
encode_other_than_array_or_object();
encode_large_integer();
escape_slashes();
encode_nul_byte();
dump_file();
Expand Down