| 46 | } |
| 47 | |
| 48 | inline bool isarray(lua_State* L, int idx, bool empty_table_as_array = false) { |
| 49 | bool arr = false; |
| 50 | if (hasJsonType(L, idx, arr)) // any table with a meta field __jsontype set to 'array' are arrays |
| 51 | return arr; |
| 52 | |
| 53 | idx = luax::absindex(L, idx); |
| 54 | lua_pushnil(L); |
| 55 | if (lua_next(L, idx) != 0) { |
| 56 | lua_pop(L, 2); |
| 57 | |
| 58 | return luax::rawlen(L, idx) > 0; // any non empty table has length > 0 are treat as array. |
| 59 | } |
| 60 | |
| 61 | // Now it comes empty table |
| 62 | return empty_table_as_array; |
| 63 | } |
| 64 | |
| 65 | |
| 66 |
no test coverage detected