[2.7] bpo-34234: Use _PyAnyInt_Check() and _PyAnyInt_CheckExact(). (GH-8479)

diff --git a/Modules/_json.c b/Modules/_json.c
index 39ec467..28c0b3f 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -1981,7 +1981,7 @@
             return -1;
         return _steal_list_append(rval, encoded);
     }
-    else if (PyInt_Check(obj) || PyLong_Check(obj)) {
+    else if (_PyAnyInt_Check(obj)) {
         PyObject *encoded = PyObject_Str(obj);
         if (encoded == NULL)
             return -1;
@@ -2131,7 +2131,7 @@
             if (kstr == NULL)
                 goto bail;
         }
-        else if (PyInt_Check(key) || PyLong_Check(key)) {
+        else if (_PyAnyInt_Check(key)) {
             kstr = PyObject_Str(key);
             if (kstr == NULL)
                 goto bail;