Reduce Loosely Typed Functions in objToJSON
State: closed

Part of my perpetual goal to simplify this. Right now we override the built-in capabilities of the JSON encoder and use multiple layers of loosely typed functions. I think this is pretty confusing, so I am trying to reduce the callbacks and set native values directly during iteration

This isn't a full solve - rather just numeric values. I plan on tackling string representations in a follow up; just stopping here because the code movement gets large fast.

In addition to less code, note that this also reduces the amount of compiler warnings from 68 down to 60 when compiling with `-Wextra`

master:

<details>

```sh
 pandas/_libs/src/ujson/python/objToJSON.c:388:28: warning: unused parameter 'obj' [-Wunused-parameter]
static void *CDouble(JSOBJ obj, JSONTypeContext *tc, void *outValue,
                           ^
pandas/_libs/src/ujson/python/objToJSON.c:389:30: warning: unused parameter '_outLen' [-Wunused-parameter]
                     size_t *_outLen) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:395:26: warning: unused parameter 'obj' [-Wunused-parameter]
static void *CLong(JSOBJ obj, JSONTypeContext *tc, void *outValue,
                         ^
pandas/_libs/src/ujson/python/objToJSON.c:396:28: warning: unused parameter '_outLen' [-Wunused-parameter]
                   size_t *_outLen) {
                           ^
pandas/_libs/src/ujson/python/objToJSON.c:402:34: warning: unused parameter '_obj' [-Wunused-parameter]
static void *PyLongToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
                                 ^
pandas/_libs/src/ujson/python/objToJSON.c:403:36: warning: unused parameter '_outLen' [-Wunused-parameter]
                           size_t *_outLen) {
                                   ^
pandas/_libs/src/ujson/python/objToJSON.c:408:60: warning: unused parameter 'tc' [-Wunused-parameter]
static void *NpyFloatToDOUBLE(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
                                                           ^
pandas/_libs/src/ujson/python/objToJSON.c:409:39: warning: unused parameter '_outLen' [-Wunused-parameter]
                              size_t *_outLen) {
                                      ^
pandas/_libs/src/ujson/python/objToJSON.c:415:59: warning: unused parameter 'tc' [-Wunused-parameter]
static void *PyFloatToDOUBLE(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
                                                          ^
pandas/_libs/src/ujson/python/objToJSON.c:416:38: warning: unused parameter '_outLen' [-Wunused-parameter]
                             size_t *_outLen) {
                                     ^
pandas/_libs/src/ujson/python/objToJSON.c:422:57: warning: unused parameter 'tc' [-Wunused-parameter]
static void *PyBytesToUTF8(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
                                                        ^
pandas/_libs/src/ujson/python/objToJSON.c:422:67: warning: unused parameter 'outValue' [-Wunused-parameter]
static void *PyBytesToUTF8(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
                                                                  ^
pandas/_libs/src/ujson/python/objToJSON.c:429:69: warning: unused parameter 'outValue' [-Wunused-parameter]
static void *PyUnicodeToUTF8(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
                                                                    ^
pandas/_libs/src/ujson/python/objToJSON.c:515:40: warning: unused parameter '_obj' [-Wunused-parameter]
static void *NpyDatetime64ToJSON(JSOBJ _obj, JSONTypeContext *tc,
                                       ^
pandas/_libs/src/ujson/python/objToJSON.c:554:40: warning: unused parameter 'obj' [-Wunused-parameter]
static int NpyTypeToJSONType(PyObject *obj, JSONTypeContext *tc, int npyType,
                                       ^
pandas/_libs/src/ujson/python/objToJSON.c:624:40: warning: unused parameter '_obj' [-Wunused-parameter]
static void NpyArr_freeItemValue(JSOBJ _obj, JSONTypeContext *tc) {
                                       ^
pandas/_libs/src/ujson/python/objToJSON.c:633:31: warning: unused parameter '_obj' [-Wunused-parameter]
int NpyArr_iterNextNone(JSOBJ _obj, JSONTypeContext *tc) { return 0; }
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:633:54: warning: unused parameter 'tc' [-Wunused-parameter]
int NpyArr_iterNextNone(JSOBJ _obj, JSONTypeContext *tc) { return 0; }
                                                     ^
pandas/_libs/src/ujson/python/objToJSON.c:690:37: warning: unused parameter 'obj' [-Wunused-parameter]
void NpyArrPassThru_iterBegin(JSOBJ obj, JSONTypeContext *tc) { PRINTMARK(); }
                                    ^
pandas/_libs/src/ujson/python/objToJSON.c:690:59: warning: unused parameter 'tc' [-Wunused-parameter]
void NpyArrPassThru_iterBegin(JSOBJ obj, JSONTypeContext *tc) { PRINTMARK(); }
                                                          ^
pandas/_libs/src/ujson/python/objToJSON.c:769:33: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ NpyArr_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                                ^
pandas/_libs/src/ujson/python/objToJSON.c:774:32: warning: unused parameter 'obj' [-Wunused-parameter]
char *NpyArr_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                               ^
pandas/_libs/src/ujson/python/objToJSON.c:828:33: warning: unused parameter 'obj' [-Wunused-parameter]
char *PdBlock_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                ^
pandas/_libs/src/ujson/python/objToJSON.c:850:43: warning: unused parameter 'obj' [-Wunused-parameter]
char *PdBlock_iterGetName_Transpose(JSOBJ obj, JSONTypeContext *tc,
                                          ^
pandas/_libs/src/ujson/python/objToJSON.c:896:38: warning: unused parameter 'obj' [-Wunused-parameter]
void PdBlockPassThru_iterBegin(JSOBJ obj, JSONTypeContext *tc) {
                                     ^
pandas/_libs/src/ujson/python/objToJSON.c:1128:26: warning: unused parameter 'obj' [-Wunused-parameter]
void Tuple_iterEnd(JSOBJ obj, JSONTypeContext *tc) {}
                         ^
pandas/_libs/src/ujson/python/objToJSON.c:1128:48: warning: unused parameter 'tc' [-Wunused-parameter]
void Tuple_iterEnd(JSOBJ obj, JSONTypeContext *tc) {}
                                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1130:32: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Tuple_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1134:31: warning: unused parameter 'obj' [-Wunused-parameter]
char *Tuple_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1134:53: warning: unused parameter 'tc' [-Wunused-parameter]
char *Tuple_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                    ^
pandas/_libs/src/ujson/python/objToJSON.c:1134:65: warning: unused parameter 'outLen' [-Wunused-parameter]
char *Tuple_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                                ^
pandas/_libs/src/ujson/python/objToJSON.c:1147:25: warning: unused parameter 'obj' [-Wunused-parameter]
int Iter_iterNext(JSOBJ obj, JSONTypeContext *tc) {
                        ^
pandas/_libs/src/ujson/python/objToJSON.c:1165:25: warning: unused parameter 'obj' [-Wunused-parameter]
void Iter_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
                        ^
pandas/_libs/src/ujson/python/objToJSON.c:1177:31: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Iter_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1181:30: warning: unused parameter 'obj' [-Wunused-parameter]
char *Iter_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:1181:52: warning: unused parameter 'tc' [-Wunused-parameter]
char *Iter_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                   ^
pandas/_libs/src/ujson/python/objToJSON.c:1181:64: warning: unused parameter 'outLen' [-Wunused-parameter]
char *Iter_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1197:24: warning: unused parameter 'obj' [-Wunused-parameter]
void Dir_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
                       ^
pandas/_libs/src/ujson/python/objToJSON.c:1283:30: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Dir_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:1288:29: warning: unused parameter 'obj' [-Wunused-parameter]
char *Dir_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                            ^
pandas/_libs/src/ujson/python/objToJSON.c:1314:25: warning: unused parameter 'obj' [-Wunused-parameter]
void List_iterEnd(JSOBJ obj, JSONTypeContext *tc) {}
                        ^
pandas/_libs/src/ujson/python/objToJSON.c:1314:47: warning: unused parameter 'tc' [-Wunused-parameter]
void List_iterEnd(JSOBJ obj, JSONTypeContext *tc) {}
                                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1316:31: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ List_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1320:30: warning: unused parameter 'obj' [-Wunused-parameter]
char *List_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:1320:52: warning: unused parameter 'tc' [-Wunused-parameter]
char *List_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                   ^
pandas/_libs/src/ujson/python/objToJSON.c:1320:64: warning: unused parameter 'outLen' [-Wunused-parameter]
char *List_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1327:28: warning: unused parameter 'obj' [-Wunused-parameter]
void Index_iterBegin(JSOBJ obj, JSONTypeContext *tc) {
                           ^
pandas/_libs/src/ujson/python/objToJSON.c:1363:26: warning: unused parameter 'obj' [-Wunused-parameter]
void Index_iterEnd(JSOBJ obj, JSONTypeContext *tc) { PRINTMARK(); }
                         ^
pandas/_libs/src/ujson/python/objToJSON.c:1363:48: warning: unused parameter 'tc' [-Wunused-parameter]
void Index_iterEnd(JSOBJ obj, JSONTypeContext *tc) { PRINTMARK(); }
                                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1365:32: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Index_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1369:31: warning: unused parameter 'obj' [-Wunused-parameter]
char *Index_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1377:29: warning: unused parameter 'obj' [-Wunused-parameter]
void Series_iterBegin(JSOBJ obj, JSONTypeContext *tc) {
                            ^
pandas/_libs/src/ujson/python/objToJSON.c:1418:27: warning: unused parameter 'obj' [-Wunused-parameter]
void Series_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
                          ^
pandas/_libs/src/ujson/python/objToJSON.c:1424:33: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Series_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                                ^
pandas/_libs/src/ujson/python/objToJSON.c:1428:32: warning: unused parameter 'obj' [-Wunused-parameter]
char *Series_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1436:32: warning: unused parameter 'obj' [-Wunused-parameter]
void DataFrame_iterBegin(JSOBJ obj, JSONTypeContext *tc) {
                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1482:30: warning: unused parameter 'obj' [-Wunused-parameter]
void DataFrame_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:1488:36: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ DataFrame_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                                   ^
pandas/_libs/src/ujson/python/objToJSON.c:1492:35: warning: unused parameter 'obj' [-Wunused-parameter]
char *DataFrame_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                  ^
pandas/_libs/src/ujson/python/objToJSON.c:1502:27: warning: unused parameter 'obj' [-Wunused-parameter]
void Dict_iterBegin(JSOBJ obj, JSONTypeContext *tc) {
                          ^
pandas/_libs/src/ujson/python/objToJSON.c:1507:25: warning: unused parameter 'obj' [-Wunused-parameter]
int Dict_iterNext(JSOBJ obj, JSONTypeContext *tc) {
                        ^
pandas/_libs/src/ujson/python/objToJSON.c:1535:25: warning: unused parameter 'obj' [-Wunused-parameter]
void Dict_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
                        ^
pandas/_libs/src/ujson/python/objToJSON.c:1544:31: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Dict_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1548:30: warning: unused parameter 'obj' [-Wunused-parameter]
char *Dict_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:2291:34: warning: unused parameter 'obj' [-Wunused-parameter]
void Object_endTypeContext(JSOBJ obj, JSONTypeContext *tc) {
                                 ^
pandas/_libs/src/ujson/python/objToJSON.c:2403:5: warning: missing field 'errorMsg' initializer [-Wmissing-field-initializers]
    }};
    ^
pandas/_libs/src/ujson/python/objToJSON.c:2403:6: warning: missing field 'npyCtxtPassthru' initializer [-Wmissing-field-initializers]
    }};
     ^
pandas/_libs/src/ujson/python/objToJSON.c:2357:31: warning: unused parameter 'self' [-Wunused-parameter]
PyObject *objToJSON(PyObject *self, PyObject *args, PyObject *kwargs) {
                              ^
68 warnings generated.
```

</details>

This PR

<details>

```sh
pandas/_libs/src/ujson/python/objToJSON.c:388:57: warning: unused parameter 'tc' [-Wunused-parameter]
static void *PyBytesToUTF8(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
                                                        ^
pandas/_libs/src/ujson/python/objToJSON.c:388:67: warning: unused parameter 'outValue' [-Wunused-parameter]
static void *PyBytesToUTF8(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
                                                                  ^
pandas/_libs/src/ujson/python/objToJSON.c:395:69: warning: unused parameter 'outValue' [-Wunused-parameter]
static void *PyUnicodeToUTF8(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
                                                                    ^
pandas/_libs/src/ujson/python/objToJSON.c:481:40: warning: unused parameter '_obj' [-Wunused-parameter]
static void *NpyDatetime64ToJSON(JSOBJ _obj, JSONTypeContext *tc,
                                       ^
pandas/_libs/src/ujson/python/objToJSON.c:520:40: warning: unused parameter 'obj' [-Wunused-parameter]
static int NpyTypeToJSONType(PyObject *obj, JSONTypeContext *tc, int npyType,
                                       ^
pandas/_libs/src/ujson/python/objToJSON.c:610:40: warning: unused parameter '_obj' [-Wunused-parameter]
static void NpyArr_freeItemValue(JSOBJ _obj, JSONTypeContext *tc) {
                                       ^
pandas/_libs/src/ujson/python/objToJSON.c:619:31: warning: unused parameter '_obj' [-Wunused-parameter]
int NpyArr_iterNextNone(JSOBJ _obj, JSONTypeContext *tc) { return 0; }
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:619:54: warning: unused parameter 'tc' [-Wunused-parameter]
int NpyArr_iterNextNone(JSOBJ _obj, JSONTypeContext *tc) { return 0; }
                                                     ^
pandas/_libs/src/ujson/python/objToJSON.c:676:37: warning: unused parameter 'obj' [-Wunused-parameter]
void NpyArrPassThru_iterBegin(JSOBJ obj, JSONTypeContext *tc) { PRINTMARK(); }
                                    ^
pandas/_libs/src/ujson/python/objToJSON.c:676:59: warning: unused parameter 'tc' [-Wunused-parameter]
void NpyArrPassThru_iterBegin(JSOBJ obj, JSONTypeContext *tc) { PRINTMARK(); }
                                                          ^
pandas/_libs/src/ujson/python/objToJSON.c:755:33: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ NpyArr_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                                ^
pandas/_libs/src/ujson/python/objToJSON.c:760:32: warning: unused parameter 'obj' [-Wunused-parameter]
char *NpyArr_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                               ^
pandas/_libs/src/ujson/python/objToJSON.c:814:33: warning: unused parameter 'obj' [-Wunused-parameter]
char *PdBlock_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                ^
pandas/_libs/src/ujson/python/objToJSON.c:836:43: warning: unused parameter 'obj' [-Wunused-parameter]
char *PdBlock_iterGetName_Transpose(JSOBJ obj, JSONTypeContext *tc,
                                          ^
pandas/_libs/src/ujson/python/objToJSON.c:882:38: warning: unused parameter 'obj' [-Wunused-parameter]
void PdBlockPassThru_iterBegin(JSOBJ obj, JSONTypeContext *tc) {
                                     ^
pandas/_libs/src/ujson/python/objToJSON.c:1114:26: warning: unused parameter 'obj' [-Wunused-parameter]
void Tuple_iterEnd(JSOBJ obj, JSONTypeContext *tc) {}
                         ^
pandas/_libs/src/ujson/python/objToJSON.c:1114:48: warning: unused parameter 'tc' [-Wunused-parameter]
void Tuple_iterEnd(JSOBJ obj, JSONTypeContext *tc) {}
                                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1116:32: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Tuple_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1120:31: warning: unused parameter 'obj' [-Wunused-parameter]
char *Tuple_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1120:53: warning: unused parameter 'tc' [-Wunused-parameter]
char *Tuple_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                    ^
pandas/_libs/src/ujson/python/objToJSON.c:1120:65: warning: unused parameter 'outLen' [-Wunused-parameter]
char *Tuple_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                                ^
pandas/_libs/src/ujson/python/objToJSON.c:1133:25: warning: unused parameter 'obj' [-Wunused-parameter]
int Iter_iterNext(JSOBJ obj, JSONTypeContext *tc) {
                        ^
pandas/_libs/src/ujson/python/objToJSON.c:1151:25: warning: unused parameter 'obj' [-Wunused-parameter]
void Iter_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
                        ^
pandas/_libs/src/ujson/python/objToJSON.c:1163:31: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Iter_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1167:30: warning: unused parameter 'obj' [-Wunused-parameter]
char *Iter_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:1167:52: warning: unused parameter 'tc' [-Wunused-parameter]
char *Iter_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                   ^
pandas/_libs/src/ujson/python/objToJSON.c:1167:64: warning: unused parameter 'outLen' [-Wunused-parameter]
char *Iter_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1183:24: warning: unused parameter 'obj' [-Wunused-parameter]
void Dir_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
                       ^
pandas/_libs/src/ujson/python/objToJSON.c:1269:30: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Dir_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:1274:29: warning: unused parameter 'obj' [-Wunused-parameter]
char *Dir_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                            ^
pandas/_libs/src/ujson/python/objToJSON.c:1300:25: warning: unused parameter 'obj' [-Wunused-parameter]
void List_iterEnd(JSOBJ obj, JSONTypeContext *tc) {}
                        ^
pandas/_libs/src/ujson/python/objToJSON.c:1300:47: warning: unused parameter 'tc' [-Wunused-parameter]
void List_iterEnd(JSOBJ obj, JSONTypeContext *tc) {}
                                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1302:31: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ List_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1306:30: warning: unused parameter 'obj' [-Wunused-parameter]
char *List_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:1306:52: warning: unused parameter 'tc' [-Wunused-parameter]
char *List_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                   ^
pandas/_libs/src/ujson/python/objToJSON.c:1306:64: warning: unused parameter 'outLen' [-Wunused-parameter]
char *List_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1313:28: warning: unused parameter 'obj' [-Wunused-parameter]
void Index_iterBegin(JSOBJ obj, JSONTypeContext *tc) {
                           ^
pandas/_libs/src/ujson/python/objToJSON.c:1349:26: warning: unused parameter 'obj' [-Wunused-parameter]
void Index_iterEnd(JSOBJ obj, JSONTypeContext *tc) { PRINTMARK(); }
                         ^
pandas/_libs/src/ujson/python/objToJSON.c:1349:48: warning: unused parameter 'tc' [-Wunused-parameter]
void Index_iterEnd(JSOBJ obj, JSONTypeContext *tc) { PRINTMARK(); }
                                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1351:32: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Index_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1355:31: warning: unused parameter 'obj' [-Wunused-parameter]
char *Index_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1363:29: warning: unused parameter 'obj' [-Wunused-parameter]
void Series_iterBegin(JSOBJ obj, JSONTypeContext *tc) {
                            ^
pandas/_libs/src/ujson/python/objToJSON.c:1404:27: warning: unused parameter 'obj' [-Wunused-parameter]
void Series_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
                          ^
pandas/_libs/src/ujson/python/objToJSON.c:1410:33: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Series_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                                ^
pandas/_libs/src/ujson/python/objToJSON.c:1414:32: warning: unused parameter 'obj' [-Wunused-parameter]
char *Series_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1422:32: warning: unused parameter 'obj' [-Wunused-parameter]
void DataFrame_iterBegin(JSOBJ obj, JSONTypeContext *tc) {
                               ^
pandas/_libs/src/ujson/python/objToJSON.c:1468:30: warning: unused parameter 'obj' [-Wunused-parameter]
void DataFrame_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:1474:36: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ DataFrame_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                                   ^
pandas/_libs/src/ujson/python/objToJSON.c:1478:35: warning: unused parameter 'obj' [-Wunused-parameter]
char *DataFrame_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                                  ^
pandas/_libs/src/ujson/python/objToJSON.c:1488:27: warning: unused parameter 'obj' [-Wunused-parameter]
void Dict_iterBegin(JSOBJ obj, JSONTypeContext *tc) {
                          ^
pandas/_libs/src/ujson/python/objToJSON.c:1493:25: warning: unused parameter 'obj' [-Wunused-parameter]
int Dict_iterNext(JSOBJ obj, JSONTypeContext *tc) {
                        ^
pandas/_libs/src/ujson/python/objToJSON.c:1521:25: warning: unused parameter 'obj' [-Wunused-parameter]
void Dict_iterEnd(JSOBJ obj, JSONTypeContext *tc) {
                        ^
pandas/_libs/src/ujson/python/objToJSON.c:1530:31: warning: unused parameter 'obj' [-Wunused-parameter]
JSOBJ Dict_iterGetValue(JSOBJ obj, JSONTypeContext *tc) {
                              ^
pandas/_libs/src/ujson/python/objToJSON.c:1534:30: warning: unused parameter 'obj' [-Wunused-parameter]
char *Dict_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) {
                             ^
pandas/_libs/src/ujson/python/objToJSON.c:2278:34: warning: unused parameter 'obj' [-Wunused-parameter]
void Object_endTypeContext(JSOBJ obj, JSONTypeContext *tc) {
                                 ^
pandas/_libs/src/ujson/python/objToJSON.c:2304:35: warning: unused parameter 'obj' [-Wunused-parameter]
JSINT64 Object_getLongValue(JSOBJ obj, JSONTypeContext *tc) {
                                  ^
pandas/_libs/src/ujson/python/objToJSON.c:2308:36: warning: unused parameter 'obj' [-Wunused-parameter]
double Object_getDoubleValue(JSOBJ obj, JSONTypeContext *tc) {
                                   ^
pandas/_libs/src/ujson/python/objToJSON.c:2380:5: warning: missing field 'errorMsg' initializer [-Wmissing-field-initializers]
    }};
    ^
pandas/_libs/src/ujson/python/objToJSON.c:2380:6: warning: missing field 'npyCtxtPassthru' initializer [-Wmissing-field-initializers]
    }};
     ^
pandas/_libs/src/ujson/python/objToJSON.c:2334:31: warning: unused parameter 'self' [-Wunused-parameter]
PyObject *objToJSON(PyObject *self, PyObject *args, PyObject *kwargs) {
                              ^
60 warnings generated.

```
</details>

Labels:
name: Refactor
description: Internal refactoring of code
name: IO JSON
description: read_json, to_json, json_normalize

Comments:
FWIW the reduction of anonymous functions here gives a little boost to performance

```sh
       before           after         ratio
     [6ffbc4ef]       [86a575f2]
     <master>         <consistent-json>
-         140±3ms          121±3ms     0.87  io.json.ToJSONLines.time_delta_int_tstamp_lines
-        90.3±2ms         73.1±3ms     0.81  io.json.ToJSON.time_to_json('split', 'df_td_int_ts')
-        80.9±2ms         63.6±2ms     0.79  io.json.ToJSON.time_to_json('values', 'df_td_int_ts')
-         105±2ms         82.0±2ms     0.78  io.json.ToJSON.time_to_json('records', 'df_td_int_ts')

SOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY.
PERFORMANCE INCREASED.
```
tentatively looks nice; will take a look in the AM
pending green (Azure fail looks unrelated) LGTM, but someone with stronger C-fu should take a look.  @chris-b1 ?
lgtm. will wait for @chris-b1 look.
Merging to continue on this one. Happy to address any comments that come up later