diff --git a/stan/model.py b/stan/model.py
index 90fc774..8e064a3 100644
--- a/stan/model.py
+++ b/stan/model.py
@@ -24,6 +24,9 @@ class DataJSONEncoder(json.JSONEncoder):
     def default(self, obj):
         if isinstance(obj, np.ndarray):
             return obj.tolist()
+        # unofficially support np.int64, np.int32, etc.
+        if hasattr(obj, "dtype") and np.issubdtype(obj.dtype, np.integer):
+            return int(obj)
         return json.JSONEncoder.default(self, obj)
 
 

diff --git a/tests/test_numpy_data.py b/tests/test_numpy_data.py
new file mode 100644
index 0000000..b6d91ab
--- /dev/null
+++ b/tests/test_numpy_data.py
@@ -0,0 +1,33 @@
+import numpy as np
+import pytest
+
+import stan
+
+program_code = """
+    data {
+    int<lower=0> N;
+    int<lower=0,upper=1> y[N];
+    }
+    parameters {
+    real<lower=0,upper=1> theta;
+    }
+    model {
+    for (n in 1:N)
+        y[n] ~ bernoulli(theta);
+    }
+    """
+
+
+def test_unsupported_type():
+    data = {"N": np.float32(10), "y": [0, 1, 0, 0, 0, 0, 0, 0, 0, 1]}
+    with pytest.raises(TypeError, match="Object of type float32 is not JSON serializable"):
+        stan.build(program_code, data=data, random_seed=1)
+
+
+def test_numpy_integer_types():
+    data = {"N": np.int64(10), "y": [0, 1, 0, 0, 0, 0, 0, 0, 0, 1]}
+    assert stan.build(program_code, data=data, random_seed=1) is not None
+    data = {"N": np.int32(10), "y": [0, 1, 0, 0, 0, 0, 0, 0, 0, 1]}
+    assert stan.build(program_code, data=data, random_seed=1) is not None
+    data = {"N": np.int16(10), "y": [0, 1, 0, 0, 0, 0, 0, 0, 0, 1]}
+    assert stan.build(program_code, data=data, random_seed=1) is not None

numpy int32 and int64 should be silently converted to Python int before sending to Stan
At least two users have complained about this. The following behavior makes me very sympathetic:

```
import numpy as np
x = np.ones(3)
x.sum().astype(int).dtype  # int64!
```

See https://discourse.mc-stan.org/t/typeerror-object-of-type-int64-is-not-json-serializable/24497 for one of the issue reports.

The conversion itself isn't problematic. Python's int type has no problem dealing with a 64-bit integer.
tests/test_numpy_data.py::test_numpy_integer_types
tests/test_numpy_data.py::test_unsupported_type