BUG: to_json failing on PyPy
State: closed

- [x] closes #39837
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them
- [x] whatsnew entry

Not sure how best to test this - confirmed this now works when run on PyPy, but since we don't test against PyPy the examples in the issue (or any other simple case) which fail on PyPy will still pass on master. 

Benchmarks look similar, might be minor performance improvement for the single block case:

```
before           after         ratio
     [b524462e]       [b1f4bcc8]
     <master>         <bug/is_mixed_type>
          194±5ms          190±2ms     0.98  io.json.ToJSONISO.time_iso_format('columns')
          208±5ms          198±6ms     0.95  io.json.ToJSONISO.time_iso_format('index')
          186±4ms          173±3ms     0.93  io.json.ToJSONISO.time_iso_format('records')
         193±10ms          187±3ms     0.97  io.json.ToJSONISO.time_iso_format('split')
          164±4ms          165±3ms     1.00  io.json.ToJSONISO.time_iso_format('values')
          115±4ms          114±3ms     0.99  io.json.ToJSONLines.time_delta_int_tstamp_lines
          142±4ms          132±6ms     0.93  io.json.ToJSONLines.time_float_int_lines
          140±4ms          142±4ms     1.02  io.json.ToJSONLines.time_float_int_str_lines
          152±2ms          153±3ms     1.01  io.json.ToJSONLines.time_float_longint_str_lines
          110±3ms          107±3ms     0.97  io.json.ToJSONLines.time_floats_with_dt_index_lines
          112±3ms          104±3ms     0.93  io.json.ToJSONLines.time_floats_with_int_idex_lines
          54.3M            55M         1.01  io.json.ToJSONMem.peakmem_float
          55.4M               55.2M    1.00  io.json.ToJSONMem.peakmem_int
          88.6±2ms         78.8±2ms    0.89  io.json.ToJSON.time_to_json('index', 'df')
          70.7±2ms         61.7±2ms    0.87  io.json.ToJSON.time_to_json('values', 'df')
          94.9±3ms         81.4±1ms    0.86  io.json.ToJSON.time_to_json('index', 'df_date_idx')
          76.3±0.9ms       65.1±1ms    0.85  io.json.ToJSON.time_to_json('records', 'df_date_idx')
```

Labels:
name: Regression
description: Functionality that used to work in a prior pandas version
name: IO JSON
description: read_json, to_json, json_normalize

Comments:
Looks harmless cc @WillAyd 
looks fine and backport ok.
Thanks for the updates. Actually reading through the history a little more I understand the length check that you've added - I didn't realize that was the case before in internals

The test isn't really what I was looking for but let's just go ahead and remove that to get this in. For context, the extension arrays I were worried about are likely commented here:

https://github.com/pandas-dev/pandas/blob/ced764da36bbc493d3ada854983638a8552d36f6/pandas/_libs/src/ujson/python/objToJSON.c#L222

We've had a rather strange history with `.values` and what actually gets read in the JSON code. At this point it appears pretty much everything uses that though. If you are interested in contributing more could definitely use help cleaning up the comments and code around that...

But yea for now let's just remove the test and merge this in
Removed the test. Thanks for pointing that out, I see what you mean now


thanks @mzeitlin11 
@meeseeksdev backport 1.2.x