From b452eed0b750c7246bf1524434c5ee4222ee1959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Y=C4=B1ld=C4=B1r=C4=B1m?= <25794892+barisyild@users.noreply.github.com> Date: Sat, 4 Jan 2025 00:51:59 +0300 Subject: [PATCH 1/3] Fix JsonPrinter Int64 Type --- std/haxe/format/JsonPrinter.hx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/std/haxe/format/JsonPrinter.hx b/std/haxe/format/JsonPrinter.hx index 20cd597cd93..7d7792c4bfb 100644 --- a/std/haxe/format/JsonPrinter.hx +++ b/std/haxe/format/JsonPrinter.hx @@ -83,7 +83,12 @@ class JsonPrinter { v = replacer(k, v); switch (Type.typeof(v)) { case TUnknown: - add('"???"'); + #if hl + if(haxe.Int64.isInt64(v)) + add(haxe.Int64.toStr(v)); + else + #end + add('"???"'); case TObject: objString(v); case TInt: @@ -125,7 +130,9 @@ class JsonPrinter { } else if (c == Date) { var v:Date = v; quote(v.toString()); - } else + } else if(haxe.Int64.isInt64(v)) + add(haxe.Int64.toStr(v)); + else classString(v); case TEnum(_): var i = Type.enumIndex(v); From 5a9430fea2ff27f0686f8a71fee2761ead165606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Y=C4=B1ld=C4=B1r=C4=B1m?= <25794892+barisyild@users.noreply.github.com> Date: Sat, 4 Jan 2025 16:30:01 +0300 Subject: [PATCH 2/3] Add Int64 Unit Test --- tests/unit/src/unit/TestJson.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/src/unit/TestJson.hx b/tests/unit/src/unit/TestJson.hx index 1509dfeab89..f9fb38c3fef 100644 --- a/tests/unit/src/unit/TestJson.hx +++ b/tests/unit/src/unit/TestJson.hx @@ -91,6 +91,7 @@ class TestJson extends Test { eq(haxe.format.JsonPrinter.print(Math.NaN), "null"); eq(haxe.format.JsonPrinter.print(function() {}), "\"\""); eq(haxe.format.JsonPrinter.print({a: function() {}, b: 1}), "{\"b\":1}"); + eq(haxe.format.JsonPrinter.print({a: function() {}, int64: haxe.Int64.parseString("123213213213213")}), "{\"int64\":123213213213213}"); } function test3690() { From c3d6b87607298aa6c3637dfb864f7436266f6460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Y=C4=B1ld=C4=B1r=C4=B1m?= <25794892+barisyild@users.noreply.github.com> Date: Sat, 4 Jan 2025 18:00:17 +0300 Subject: [PATCH 3/3] Delete unnecessary code from Json Int64 Test --- tests/unit/src/unit/TestJson.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/src/unit/TestJson.hx b/tests/unit/src/unit/TestJson.hx index f9fb38c3fef..b72015a7547 100644 --- a/tests/unit/src/unit/TestJson.hx +++ b/tests/unit/src/unit/TestJson.hx @@ -91,7 +91,7 @@ class TestJson extends Test { eq(haxe.format.JsonPrinter.print(Math.NaN), "null"); eq(haxe.format.JsonPrinter.print(function() {}), "\"\""); eq(haxe.format.JsonPrinter.print({a: function() {}, b: 1}), "{\"b\":1}"); - eq(haxe.format.JsonPrinter.print({a: function() {}, int64: haxe.Int64.parseString("123213213213213")}), "{\"int64\":123213213213213}"); + eq(haxe.format.JsonPrinter.print({int64: haxe.Int64.parseString("123213213213213")}), "{\"int64\":123213213213213}"); } function test3690() {